Support Forums

Full Version: [Help] Vb 2008 CheckBoxes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
[Image: 2llhpgx.jpg]

How do I make it that only one of it can be checked at a time? So if they check any others, it automatically unchecks the previous one that was checked.

Thanks.
(12-11-2009, 01:01 AM)HmanDude Wrote: [ -> ][Image: 2llhpgx.jpg]

How do I make it that only one of it can be checked at a time? So if they check any others, it automatically unchecks the previous one that was checked.

Thanks.

The whole reason for checkbox's was so you can check multiple box's.

For one selection you should be using radio buttons.

Anyway, refer to here.

http://social.msdn.microsoft.com/Forums/...c26631d31e

Should be helpful.
You should use RadioButtons to select one Checkboxes are for selecting many
Just use this :
Just use this (radiobuttons) :

Code:
If RadioButton1.Checked = True Then
            RadioButton2.Checked = False
            RadioButton3.Checked = False
        ElseIf RadioButton2.Checked = True Then
            RadioButton1.Checked = False
            RadioButton3.Checked = False
        ElseIf RadioButton3.Checked = True Then
            RadioButton1.Checked = False
            RadioButton2.Checked = False
        End If

Yeye[/quote]
(12-11-2009, 09:10 AM)dunlop03 Wrote: [ -> ]Just use this :
Just use this (radiobuttons) :

Code:
If RadioButton1.Checked = True Then
            RadioButton2.Checked = False
            RadioButton3.Checked = False
        ElseIf RadioButton2.Checked = True Then
            RadioButton1.Checked = False
            RadioButton3.Checked = False
        ElseIf RadioButton3.Checked = True Then
            RadioButton1.Checked = False
            RadioButton2.Checked = False
        End If

Yeye

yes this is the right answer but , you wanted it for checkbox so replace RadioButton1 with CheckBox1 and etc ..

radio buttons adn checkboxes are 2 different controls
That wont work , trust me you need to code the check boxes like this :

Code:
Private Sub CheckBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.Click
        If CheckBox1.Checked = True Then
            CheckBox2.Checked = False
            CheckBox3.Checked = False
     End If
    End Sub

    Private Sub CheckBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.Click
        If CheckBox2.Checked = True Then
            CheckBox1.Checked = False
            CheckBox3.Checked = False
        End If
    End Sub

    Private Sub CheckBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.Click

        If CheckBox3.Checked = True Then
            CheckBox1.Checked = False
            CheckBox2.Checked = False
        End If
    End Sub
[/quote]
Thanks guys. dunlop03 your code works for me atm.

Also using RadioButtons on another project im working on so thanks Smile
Np m8 , glad you got it working. Smile
I'm not sure that code is neccasery
Code:
If RadioButton1.Checked = True Then
            RadioButton2.Checked = False
            RadioButton3.Checked = False
        ElseIf RadioButton2.Checked = True Then
            RadioButton1.Checked = False
            RadioButton3.Checked = False
        ElseIf RadioButton3.Checked = True Then
            RadioButton1.Checked = False
            RadioButton2.Checked = False
        End If

When i use radio buttons and for example i use radiobutton 1, than i change to radiobutton 2, number 1 disappear.

Sorry for bad explanation, and sorry if I am wrong.
No m8 ur correct , but its different for radiobuttons and checkboxes , slightly
Pages: 1 2