checkstatechange of any checkbox

Joined
Mar 13, 2007
Messages
5
Programming Experience
Beginner
Hi

I've got a form with 64 checkboxes on. Is there an event that can trigger when the state of any of these change (they're all in the same collection).

Thanks
Simon
 
Loop the Controls collection to add the same event handler for all checkboxes.
VB.NET:
Sub addhandlers()
    For Each c As Control In Me.Controls
        If TypeOf c Is CheckBox Then
            AddHandler DirectCast(c, CheckBox).CheckedChanged, AddressOf CheckBoxes_CheckedChanged
        End If
    Next
End Sub
  
Private Sub CheckBoxes_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim cb As CheckBox = sender
 
End Sub
 
Back
Top