E
eBob.com
Despite my bad cold and headache I should be able to correctly code
what I am trying to code below. Or should at least be able to
determine why such simple code does not work. I do have very similar
but more complicated code working in another project (thanks, I might
add, to several people here who have helped me).
The problem is that I never see the Labels. Using the debugger I can
see that the Text property of the Labels are correct. I could not
verify from the debugger that the Labels are actually being added to
the Panel Control, but I do not see how they could not be.
Dim chkbxSel(9) As CheckBox
Dim lbl(9) As Label
+ " Windows Form Designer generated code "
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) _
Handles Button1.Click
'populate panel
Dim yloc As Integer = 0
For i As Integer = 0 To 9
lbl(i) = New Label
yloc = i * (lbl(i).Height + 4)
chkbxSel(i) = New CheckBox
chkbxSel(i).Tag = i
chkbxSel(i).Location = New Point(0, yloc)
lbl(i).Width = 200
lbl(i).Text = "CheckBox " & i.ToString
lbl(i).Location = New Point(20, yloc)
Panel1.Controls.Add(chkbxSel(i)) ' < I see the
CheckBoxes
Panel1.Controls.Add(lbl(i)) ' < But I do not
see the Labels
Next
End Sub
what I am trying to code below. Or should at least be able to
determine why such simple code does not work. I do have very similar
but more complicated code working in another project (thanks, I might
add, to several people here who have helped me).
The problem is that I never see the Labels. Using the debugger I can
see that the Text property of the Labels are correct. I could not
verify from the debugger that the Labels are actually being added to
the Panel Control, but I do not see how they could not be.
Dim chkbxSel(9) As CheckBox
Dim lbl(9) As Label
+ " Windows Form Designer generated code "
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) _
Handles Button1.Click
'populate panel
Dim yloc As Integer = 0
For i As Integer = 0 To 9
lbl(i) = New Label
yloc = i * (lbl(i).Height + 4)
chkbxSel(i) = New CheckBox
chkbxSel(i).Tag = i
chkbxSel(i).Location = New Point(0, yloc)
lbl(i).Width = 200
lbl(i).Text = "CheckBox " & i.ToString
lbl(i).Location = New Point(20, yloc)
Panel1.Controls.Add(chkbxSel(i)) ' < I see the
CheckBoxes
Panel1.Controls.Add(lbl(i)) ' < But I do not
see the Labels
Next
End Sub