在用户控件中,在运行时,我在tablelayoutpanel中创建了5行和3列。我用控件填充的单元格:标签,文本框,复选框.....工作......
这是我的代码:
Private Sub GenerateGUI(Cboxes As Integer, Tboxes As Integer)
tlp.Controls.Clear()
tlp.RowStyles.Clear()
tlp.ColumnStyles.Clear()
If Cboxes > 0 And Tboxes > 0 Then
tlp.RowStyles.Add(New RowStyle(SizeType.Percent, 20%))
tlp.RowCount = Checkboxes
tlp.ColumnStyles.Add(New ColumnStyle(SizeType.AutoSize))
tlp.ColumnCount = 3
For i = 1 To Checkboxes
Dim L As New Label, TB As New TextBox, CB As New CheckBox
With L
.Dock = DockStyle.Fill
.Visible = True
.Text = Chr(64 + i) '65 = capital A
.Font = New Font("Microsoft Sans Serif", 11, FontStyle.Bold)
.BackColor = Color.Aqua
End With
With TB
.Name = "txt" & i
.Dock = DockStyle.Fill
.Visible = True
.Multiline = True
.Font = New Font("Microsoft Sans Serif", 11, FontStyle.Regular)
.ScrollBars = ScrollBars.Vertical
End With
With CB
.Name = "chk" & i
.Dock = DockStyle.Fill
.Visible = True
.BackColor = Color.LightGray
End With
tlp.Controls.Add(L, 0, i - 1)
tlp.Controls.Add(TB, 1, i - 1)
tlp.Controls.Add(CB, 2, i - 1)
Next
End Sub
这就是它的样子:
http://i42.tinypic.com/2ibcnqb.png
在图片中你也看到它应该如何。我究竟做错了什么?我没有想法.....