I have an array of checkboxes and a form with multiple checkboxes on it. I want a counter that displays (in real time) how many are checked.
Rather than coding a duplicate "_CheckedChanged()" event for every single one, is there a way to have a single _CheckedChanged() even for the entire array?
> Private Sub frmMain_Load(...
> Dim intChecked as Integer = 0
> checkboxes = New CheckBox() {cbxTrackDefault, chkThumb01, chkThumb02, chkThumb03, ...
(What I've tried. DOESN'T WORK. Clearly, I don't know what I'm doing.)
> Private Sub CheckboxHandler(ByVal sender As CheckBox, ByVal e As System.EventArgs)
> Dim position As Integer = 0
> position = Array.IndexOf(checkboxes, checkboxes)
> AddHandler checkboxes(position).CheckedChanged, AddressOf CheckboxHandler
> If sender.Checked = True Then
> intChecked += 1
> Else
> intChecked -= 1
> End If
> lblChecked.Text = intChecked
> End Sub
There must be a simple solution. Any assistance appreciated. TIA