Hey Guys
Quick question which I'm sure is actually pretty simple but I'm pretty new to this.
I have a piece of code for a program where when a specific checkbox is checked\uncheck ed (In this case "Allyellow" ) it checks\unchecks any checkboxes within a group of 14 with a lightyellow backcolor.
While the piece of code below does this fine it seems to me to be very clunky and it must be possible to streamline it.
Any help would be much appriciated
Thanks
Dave
Quick question which I'm sure is actually pretty simple but I'm pretty new to this.
I have a piece of code for a program where when a specific checkbox is checked\uncheck ed (In this case "Allyellow" ) it checks\unchecks any checkboxes within a group of 14 with a lightyellow backcolor.
While the piece of code below does this fine it seems to me to be very clunky and it must be possible to streamline it.
Any help would be much appriciated
Thanks
Dave
Code:
Private Sub Allyellow_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Allyellow.CheckedChanged
If Allyellow.Checked = True Then
If CheckBox1.BackColor = Color.LightYellow Then
CheckBox1.Checked = True
End If
If CheckBox2.BackColor = Color.LightYellow Then
CheckBox2.Checked = True
End If
If CheckBox3.BackColor = Color.LightYellow Then
CheckBox3.Checked = True
End If
If CheckBox4.BackColor = Color.LightYellow Then
CheckBox4.Checked = True
End If
If CheckBox5.BackColor = Color.LightYellow Then
CheckBox5.Checked = True
End If
If CheckBox6.BackColor = Color.LightYellow Then
CheckBox6.Checked = True
End If
If CheckBox7.BackColor = Color.LightYellow Then
CheckBox7.Checked = True
End If
If CheckBox8.BackColor = Color.LightYellow Then
CheckBox8.Checked = True
End If
If CheckBox9.BackColor = Color.LightYellow Then
CheckBox9.Checked = True
End If
If CheckBox10.BackColor = Color.LightYellow Then
CheckBox10.Checked = True
End If
If CheckBox11.BackColor = Color.LightYellow Then
CheckBox11.Checked = True
End If
If CheckBox12.BackColor = Color.LightYellow Then
CheckBox12.Checked = True
End If
If CheckBox13.BackColor = Color.LightYellow Then
CheckBox13.Checked = True
End If
If CheckBox14.BackColor = Color.LightYellow Then
CheckBox14.Checked = True
End If
ElseIf Allyellow.Checked = False Then
If CheckBox1.BackColor = Color.LightYellow Then
CheckBox1.Checked = False
End If
If CheckBox2.BackColor = Color.LightYellow Then
CheckBox2.Checked = False
End If
If CheckBox3.BackColor = Color.LightYellow Then
CheckBox3.Checked = False
End If
If CheckBox4.BackColor = Color.LightYellow Then
CheckBox4.Checked = False
End If
If CheckBox5.BackColor = Color.LightYellow Then
CheckBox5.Checked = False
End If
If CheckBox6.BackColor = Color.LightYellow Then
CheckBox6.Checked = False
End If
If CheckBox7.BackColor = Color.LightYellow Then
CheckBox7.Checked = False
End If
If CheckBox8.BackColor = Color.LightYellow Then
CheckBox8.Checked = False
End If
If CheckBox9.BackColor = Color.LightYellow Then
CheckBox9.Checked = False
End If
If CheckBox10.BackColor = Color.LightYellow Then
CheckBox10.Checked = False
End If
If CheckBox11.BackColor = Color.LightYellow Then
CheckBox11.Checked = False
End If
If CheckBox12.BackColor = Color.LightYellow Then
CheckBox12.Checked = False
End If
If CheckBox13.BackColor = Color.LightYellow Then
CheckBox13.Checked = False
End If
If CheckBox14.BackColor = Color.LightYellow Then
CheckBox14.Checked = False
End If
End If
End Sub
Comment