one way would be to place the checkboxes in 1 groupbox then on the checkedchanged event for each checkbox, if the current checkbox is checked then for each checkbox in the groupbox - set the current checkbox in the iteration loop to checked (true)
example...
private sub Checkbox1_CheckedChanged(byval sender as object, byval e as eventargs) handles Checkbox1.CheckedChanged
if Me.Checkbox1.Checked = true then
for each currentCheckbox as CheckBox in Me.groupBox1.Controls
currentCheckbox.Checked = true
next
end if
end sub
this is just 1 example, which has no error checking to see if the current control is infact a checkbox or not.
is this what you maybe after?
private sub Checkbox1_CheckedChanged(byval sender as object, byval e as eventargs) handles Checkbox1.CheckedChanged, Checkbox2.CheckedChanged, Checkbox3.ChecledChanged
if Sender=CheckBox1 then
Checkbox2.Checked=CheckBox1.Checked
Checkbox3.Checked=Checkbox1.checked
elseif Sender=CheckBox2 then
Checkbox1.Checked=CheckBox1.Checked
Checkbox3.Checked=Checkbox1.checked
elseif Sender=Checkbox3 then
Checkbox1.Checked=CheckBox1.Checked Checkbox2.Checked=Checkbox1.checked end if
end sub
You also can create a form-level property like that:
Private Property MyGroupChecked() As Boolean
Get
Return CheckBox1.Checked
End Get
Set (ByVal Value As Boolean)
CheckBox1.Checked = Value
CheckBox2.Checked = Value
' and so on ...
End Set
End Property
And then, write this event handler:
Private Sub MyGroupHandler(ByVal sender As Object, ByVal e As EventArgs) Handles _
CheckBox1.CheckedChanged, CheckBox2.CheckedChanged ' and so on ...
MyGroupChecked = CType(sender, CheckBox).Checked
End Sub
This is little more flexible and allows you to change the state of checkboxes programmatically in one line of code:
MyGroupChecked = True