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.BorderStyle = BorderStyle.FixedSingle Then
lblP1JoyUp.Top = 10
lblP1JoyUp.Left = 10
lblP1JoyUp.Height = 24
lblP1JoyUp.Width = 100
lblP1JoyUp.Visible = False
lblP1JoyUp.BackColor = Color.Transparent
lblP1JoyUp.ForeColor = Color.White
lblP1JoyUp.Font = frm1.Font
lblP1JoyUp.BorderStyle = BorderStyle.None
frmLC.chkP1JoyUp.Checked = False
End If
It checks to see if a label is selected (Borderstyle.FixedSingle) 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.BorderStyle = BorderStyle.FixedSingle Then
'Dim strlblCheck As CheckBox
'strlblCheck.Name = "chk" & ctrl.ToString
ctrl.Top = 10
ctrl.Left = 10
ctrl.Height = 24
ctrl.Width = 100
ctrl.Visible = False
ctrl.BackColor = Color.Transparent
ctrl.ForeColor = Color.White
ctrl.Font = frm1.Font
ctrl.BorderStyle = BorderStyle.None
'frmLC.strlblcheck.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