I have an application which uses 26 checkboxes and requires a checkbox to be set to checked when its associatand button is pressed and all other checkboxes set to unchecked. The code I am using is shown below, not too elegent can I use for next loops to achieve the same.
Private Sub ButtB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtB.Click
CheckBox1.CheckState = CheckState.Unchecked
CheckBox2.CheckState = CheckState.Checked
CheckBox3.CheckState = CheckState.Unchecked
CheckBox4.CheckState = CheckState.Unchecked
CheckBox5.CheckState = CheckState.Unchecked
CheckBox6.CheckState = CheckState.Unchecked
CheckBox7.CheckState = CheckState.Unchecked
CheckBox8.CheckState = CheckState.Unchecked
CheckBox9.CheckState = CheckState.Unchecked
CheckBox10.CheckState = CheckState.Unchecked
CheckBox11.CheckState = CheckState.Unchecked
CheckBox12.CheckState = CheckState.Unchecked
CheckBox13.CheckState = CheckState.Unchecked
CheckBox14.CheckState = CheckState.Unchecked
CheckBox15.CheckState = CheckState.Unchecked
CheckBox16.CheckState = CheckState.Unchecked
CheckBox17.CheckState = CheckState.Unchecked
CheckBox18.CheckState = CheckState.Unchecked
CheckBox19.CheckState = CheckState.Unchecked
CheckBox20.CheckState = CheckState.Unchecked
CheckBox21.CheckState = CheckState.Unchecked
CheckBox22.CheckState = CheckState.Unchecked
CheckBox23.CheckState = CheckState.Unchecked
CheckBox24.CheckState = CheckState.Unchecked
CheckBox25.CheckState = CheckState.Unchecked
CheckBox26.CheckState = CheckState.Unchecked
End Sub
Private Sub ButtB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtB.Click
CheckBox1.CheckState = CheckState.Unchecked
CheckBox2.CheckState = CheckState.Checked
CheckBox3.CheckState = CheckState.Unchecked
CheckBox4.CheckState = CheckState.Unchecked
CheckBox5.CheckState = CheckState.Unchecked
CheckBox6.CheckState = CheckState.Unchecked
CheckBox7.CheckState = CheckState.Unchecked
CheckBox8.CheckState = CheckState.Unchecked
CheckBox9.CheckState = CheckState.Unchecked
CheckBox10.CheckState = CheckState.Unchecked
CheckBox11.CheckState = CheckState.Unchecked
CheckBox12.CheckState = CheckState.Unchecked
CheckBox13.CheckState = CheckState.Unchecked
CheckBox14.CheckState = CheckState.Unchecked
CheckBox15.CheckState = CheckState.Unchecked
CheckBox16.CheckState = CheckState.Unchecked
CheckBox17.CheckState = CheckState.Unchecked
CheckBox18.CheckState = CheckState.Unchecked
CheckBox19.CheckState = CheckState.Unchecked
CheckBox20.CheckState = CheckState.Unchecked
CheckBox21.CheckState = CheckState.Unchecked
CheckBox22.CheckState = CheckState.Unchecked
CheckBox23.CheckState = CheckState.Unchecked
CheckBox24.CheckState = CheckState.Unchecked
CheckBox25.CheckState = CheckState.Unchecked
CheckBox26.CheckState = CheckState.Unchecked
End Sub