473,473 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

checking if any radio buttons are checked

Hello all,

Given I have a GroupBox named grpChoices, within this box i have 8
radiobuttons, named rbtButton1 through rbtButton8.
Now I would like to have a button btnOK which is enabled=false as long as
none of the radiobuttons in grpChoices are checked, and enabled=true when
the user checks one of the radiobuttons.

does anyone have an idea on how to do this, I have seached the documentation
but still no luck (then again I'm not a lucky guy)
thanks

Remi
Nov 20 '05 #1
4 6126
You could do it like this (you have to add the 8 radbuttons)

Private Sub RadioButton_CheckedChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles rbtButton1 .CheckedChanged,
rbtButton8.CheckedChanged
Dim rad As RadioButton
btnOK.Enabled = False
For Each rad In grpChoices.Controls
If rad.Checked Then
btnOK.Enabled = True
End If
Next
End Sub

or if the button stays true after you selected something

Private Sub RadioButton_CheckedChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles rbtButton1 .CheckedChanged,
rbtButton8.CheckedChanged
btnOK.Enabled = True

End Sub

"Remi Lillelien" <re**************@eunet.no> wrote in message
news:c4**********@services.kq.no...
Hello all,

Given I have a GroupBox named grpChoices, within this box i have 8
radiobuttons, named rbtButton1 through rbtButton8.
Now I would like to have a button btnOK which is enabled=false as long as
none of the radiobuttons in grpChoices are checked, and enabled=true when
the user checks one of the radiobuttons.

does anyone have an idea on how to do this, I have seached the documentation but still no luck (then again I'm not a lucky guy)
thanks

Remi

Nov 20 '05 #2
You could do it like this (you have to add the 8 radbuttons)

Private Sub RadioButton_CheckedChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles rbtButton1 .CheckedChanged,
rbtButton8.CheckedChanged
Dim rad As RadioButton
btnOK.Enabled = False
For Each rad In grpChoices.Controls
If rad.Checked Then
btnOK.Enabled = True
End If
Next
End Sub

or if the button stays true after you selected something

Private Sub RadioButton_CheckedChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles rbtButton1 .CheckedChanged,
rbtButton8.CheckedChanged
btnOK.Enabled = True

End Sub

"Remi Lillelien" <re**************@eunet.no> wrote in message
news:c4**********@services.kq.no...
Hello all,

Given I have a GroupBox named grpChoices, within this box i have 8
radiobuttons, named rbtButton1 through rbtButton8.
Now I would like to have a button btnOK which is enabled=false as long as
none of the radiobuttons in grpChoices are checked, and enabled=true when
the user checks one of the radiobuttons.

does anyone have an idea on how to do this, I have seached the documentation but still no luck (then again I'm not a lucky guy)
thanks

Remi

Nov 20 '05 #3
Remi -

One option would be to put this code in all the radio buttons check
changed event (remembering to change the index of the radio button):

If RadioButton1.Checked = True Then
Button1.Enabled = True
Else
Button1.Enabled = False
End If

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 20 '05 #4
Remi -

One option would be to put this code in all the radio buttons check
changed event (remembering to change the index of the radio button):

If RadioButton1.Checked = True Then
Button1.Enabled = True
Else
Button1.Enabled = False
End If

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeff | last post by:
I'm trying to create a dynamic form that can have multiple groups of radio buttons (each group has two buttons) with the same name. Essentially, the form allows a user to enter as many names as...
4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
6
by: Craig Keightley | last post by:
I have a page that has n number of radio groups (yes/No) how can i prevent the form being submitted if more than one radio group is not selected? By default all radio groups are unchecked ...
2
by: Jeff | last post by:
I'm trying to create a dynamic form that can have multiple groups of radio buttons (each group has two buttons) with the same name. Essentially, the form allows a user to enter as many names as...
0
by: Shadow Lynx | last post by:
In standard HTML, the <INPUT type="radio" name="x" /control only allows one radio button to be checked at a time. When more than one are set as checked="true" then only the last one rendered...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.