I am trying trying to loop through some label controls and setting some
properties for the labels I'm looping through. Currently I am addressing the
labels one at a time with IF...Then logic, like this:
If lblP1JoyUp.Bord erStyle = BorderStyle.Fix edSingle Then
lblP1JoyUp.Top = 10
lblP1JoyUp.Left = 10
lblP1JoyUp.Heig ht = 24
lblP1JoyUp.Widt h = 100
lblP1JoyUp.Visi ble = False
lblP1JoyUp.Back Color = Color.Transpare nt
lblP1JoyUp.Fore Color = Color.White
lblP1JoyUp.Font = frm1.Font
lblP1JoyUp.Bord erStyle = BorderStyle.Non e
frmLC.chkP1JoyU p.Checked = False
End If
It checks to see if a label is selected (Borderstyle.Fi xedSingle) and if so.
Changes a bunch of the labels properties. I don't have a problem changing
this code with my loop. However, the last line sets the status of a checkbox
on a different form. As you can see the checkbox name corresponds with the
labelname. I can't seem to figure out how to address the checkbox in my loop
code. Here is my loop code:
For Each ctrl As Label In Me.Controls
If TypeOf ctrl Is Label Then
If ctrl.BorderStyl e = BorderStyle.Fix edSingle Then
'Dim strlblCheck As CheckBox
'strlblCheck.Na me = "chk" & ctrl.ToString
ctrl.Top = 10
ctrl.Left = 10
ctrl.Height = 24
ctrl.Width = 100
ctrl.Visible = False
ctrl.BackColor = Color.Transpare nt
ctrl.ForeColor = Color.White
ctrl.Font = frm1.Font
ctrl.BorderStyl e = BorderStyle.Non e
'frmLC.strlblch eck.Checked = False
End If
End If
Next
You can see by the commented lines that I've tried a few things, but no
luck yet. What do I need to do here?
Thanks,
John