473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 6120
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.