Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Help] Vb 2008 CheckBoxes
#1
[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.
Reply
#2
(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.
[Image: Untitled-1.png]
Reply
#3
You should use RadioButtons to select one Checkboxes are for selecting many
Reply
#4
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]
Reply
#5
(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
Reply
#6
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]
Reply
#7
Thanks guys. dunlop03 your code works for me atm.

Also using RadioButtons on another project im working on so thanks Smile
Reply
#8
Np m8 , glad you got it working. Smile
Reply
#9
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.
Reply
#10
No m8 ur correct , but its different for radiobuttons and checkboxes , slightly
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  VB 2008 - Useful Code Apache 36 16,069 11-25-2012, 10:37 PM
Last Post: ƃu∀ ıʞƃu∀
  [Pandora Incorporated] Visual Basic 2008 - Source Code Grabber [VIDEO TUTORIAL] Marik™ 13 4,678 05-23-2011, 06:41 PM
Last Post: KoBE
  [Pandora Incorporated]Visual Basic 2008 -MD5 Encryptor [VIDEO TUTORIAL] Marik™ 2 1,662 05-13-2011, 11:06 AM
Last Post: Imports System.Net
  [Pandora Incorporated] Visual Basic 2008 - Text To Speech [VIDEO TUTORIAL] Marik™ 1 1,577 04-14-2011, 05:37 PM
Last Post: Emily
  [Help] [VB.NET 2008] Textbox Contents Encryption. Example 4 4,010 02-23-2011, 01:16 AM
Last Post: Example

Forum Jump:


Users browsing this thread: 1 Guest(s)