Vb.net TableLayoutPanel行重叠,而每隔第二个备用行控件可见true / false

时间:2018-10-13 06:01:44

标签: vb.net winforms tablelayoutpanel

小概述:-

(假设行索引以1开头,则更加清晰) 我有奇数行(1、3、5 ...)药品信息。
每隔一行(2,4,6 ...)都有一个特殊的说明字段,该字段是可选的 我默认情况下保持可见=假。

因此,当单击相应的控件TextBox(下一行)的可见属性时,我在第一行的每一行都保留了一个按钮(1、3、5 ...),可见属性分配为true / false(切换按钮)。
第二行只有一个TextBox控件。
因此,当TextBox控件为false时,则期望第二行的高度自动为零,而当其为true时,相应的第二行应可见。

我已将所有行的高度设置为自动调整大小

问题:-
单击按钮时,TextBox重叠在第三行(3,5,7 ....),而不是显示在其适当的第二行(2,4,6 ...) 当我将TextBox设置为default visible = true时,它将正确地占用第二行。但是它不必要地占用了很多空间。如上所述,由于TextBox项是可选的,并非每次都需要。

以下是一些让我的问题更加清晰的建议:-

TableLayoutPanel

图1:TableLayout设计


Overlapped on third row instead of taking visible second row

图2:在第三行上重叠,而不是在可见的第二行上


When second row TextBox visible is set true by default

图3:默认情况下,第二行TextBox visible设置为true


在按钮后面的

我的代码单击:-

Private Sub Button_Drug_Dosage_General_Instructions_Click(
                                                            sender As Object, e As EventArgs
                                                         ) Handles Button_Drug_Dosage_General_Instructions_20.Click,
                                                                    Button_Drug_Dosage_General_Instructions_19.Click,
                                                                    Button_Drug_Dosage_General_Instructions_18.Click,
                                                                    Button_Drug_Dosage_General_Instructions_17.Click,
                                                                    Button_Drug_Dosage_General_Instructions_16.Click,
                                                                    Button_Drug_Dosage_General_Instructions_15.Click,
                                                                    Button_Drug_Dosage_General_Instructions_14.Click,
                                                                    Button_Drug_Dosage_General_Instructions_13.Click,
                                                                    Button_Drug_Dosage_General_Instructions_12.Click,
                                                                    Button_Drug_Dosage_General_Instructions_11.Click,
                                                                    Button_Drug_Dosage_General_Instructions_10.Click,
                                                                    Button_Drug_Dosage_General_Instructions_09.Click,
                                                                    Button_Drug_Dosage_General_Instructions_08.Click,
                                                                    Button_Drug_Dosage_General_Instructions_07.Click,
                                                                    Button_Drug_Dosage_General_Instructions_06.Click,
                                                                    Button_Drug_Dosage_General_Instructions_05.Click,
                                                                    Button_Drug_Dosage_General_Instructions_04.Click,
                                                                    Button_Drug_Dosage_General_Instructions_03.Click,
                                                                    Button_Drug_Dosage_General_Instructions_02.Click,
                                                                    Button_Drug_Dosage_General_Instructions_01.Click

    If Initialization_In_Progress = True Then Exit Sub

    '------------------------------------------------------------------------------------------------
    'Button_Drug_Dosage_General_Instructions_obj
    '------------------------------------------------------------------------------------------------
    Dim btn_Button_Drug_Dosage_General_Instructions_obj As Button = CType(sender, Button)
    '------------------------------------------------------------------------------------------------

    '------------------------------------------------------------------------------------------------
    Dim object_name As String = btn_Button_Drug_Dosage_General_Instructions_obj.Name
    Dim xCustomer_Selected_srno As Double = object_name.Substring(object_name.Length - 2)
    '------------------------------------------------------------------------------------------------
    '------------------------------------------------------------------------------------------------
    Dim txtbox_TextBox_General_Instructions_obj As TextBox = CType(Me.Controls.Find("TextBox_Drug_Dosage_General_Instructions_" + (xCustomer_Selected_srno).ToString("00"), True)(0), TextBox)
    '------------------------------------------------------------------------------------------------
    If txtbox_TextBox_General_Instructions_obj.Visible = False Then

        txtbox_TextBox_General_Instructions_obj.Visible = True
        txtbox_TextBox_General_Instructions_obj.SelectionLength = 0

    Else

        txtbox_TextBox_General_Instructions_obj.Visible = False

    End If

End Sub

希望我已尽力提出确切的问题。如果仍然需要更多信息,我一定会发表。

我的其他锻炼:-

尝试了TextBox码头填充,无,锚定顶部,左侧,也全部使用了RowHeight绝对,但没有任何效果。

0 个答案:

没有答案