I have 6 checkboxes in a Groupbox, the Checkboxes are named myCheckbox(0) to myCheckbox(5)
I would like to be able to choose only one checkbox, if one is selected already then selecting another one deselects the already selected one and selects the just selected one.
I have this code
Dim i as integer = me.Index
For i = 0 to 5
if i = me.index then
Section1CB(i).State = Checkbox.CheckedStates.Checked
Section1Score = i
Section1CB(i).State = Checkbox.CheckedStates.Unchecked
but when it is the action event all the checkboxes are selected when one is selected.
when it is the mouse down event more than one can be selected.
The same code works well on Mac in the action event.
How can I achieve my aim?
This is not what checkboxes are for. Use radio buttons.
Checkboxes imply multiple selection allowed, radio buttons imply only one selection allowed.
Edit: Another benefit is you won’t need any code to achieve the effect you desire (because that’s what radio buttons are for).
I will try that and let you know.
I wonder how many people here remember WHY they are called that?
Think… before Sirius Radio, before DVD, before CD, before even most FM radio!
The AM radio in your car had pushbuttons for your favorite stations … and when you pushed one, any other that had been pushed in, popped out, so you could never have more than one selected at a time
I may be young, but I do know where they got their name!
Just like the buttons on an 8-track player