Joyce Tan
Joyce Tan

Reputation: 11

After i checked the checkbox option , why my checkbox option text change to checked?

I am doing a quiz in VB so I have the question form with the question and the checkbox option . After i checked the checkbox option , why my checkbox option text change to checked ? If I return to the previous question ?

This is my code for one of my option :

Private Sub Option1CheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Option1CheckBox.CheckedChanged

        If Option1CheckBox.Checked = True Then

            Option4CheckBox.Checked = False
            Option2CheckBox.Checked = False
            Option3CheckBox.Checked = False



        End If

    End Sub

Upvotes: 0

Views: 1461

Answers (2)

user1218115
user1218115

Reputation:

That is because you are using the event "CheckedChanged" which ticks or unticks the checkbox as soon as you click on it.

Try using the "Click" event and then you can put code to either check the checkbox or leave it unchecked

Upvotes: 0

Mark Hall
Mark Hall

Reputation: 54562

My guess is that you have a Typo in some of the Code you are not showing us. If you want to have it only allow one selection use a RadioButton instead.

From above link:

Enables the user to select a single option from a group of choices when paired with other RadioButton controls.

Upvotes: 1

Related Questions