Support Forums
[Help] Vb 2008 CheckBoxes - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19)
+---- Thread: [Help] Vb 2008 CheckBoxes (/showthread.php?tid=3520)

Pages: 1 2


[Help] Vb 2008 CheckBoxes - HmanDude - 12-11-2009

[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.


RE: [Help] Vb 2008 CheckBoxes - Bartdevil - 12-11-2009

(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/en-US/vbgeneral/thread/d419b8c5-dea9-4434-897a-20c26631d31e

Should be helpful.


RE: [Help] Vb 2008 CheckBoxes - ViT0 - 12-11-2009

You should use RadioButtons to select one Checkboxes are for selecting many


RE: [Help] Vb 2008 CheckBoxes - dunlop03 - 12-11-2009

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]


RE: [Help] Vb 2008 CheckBoxes - spiro_dt - 12-11-2009

(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


RE: [Help] Vb 2008 CheckBoxes - dunlop03 - 12-11-2009

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]


RE: [Help] Vb 2008 CheckBoxes - HmanDude - 12-11-2009

Thanks guys. dunlop03 your code works for me atm.

Also using RadioButtons on another project im working on so thanks Smile


RE: [Help] Vb 2008 CheckBoxes - dunlop03 - 12-11-2009

Np m8 , glad you got it working. Smile


RE: [Help] Vb 2008 CheckBoxes - p1g 0wnz - 12-28-2009

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.


RE: [Help] Vb 2008 CheckBoxes - dunlop03 - 12-29-2009

No m8 ur correct , but its different for radiobuttons and checkboxes , slightly