By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,116 Members | 1,509 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,116 IT Pros & Developers. It's quick & easy.

Checking for Radio buttons

P: n/a
Hi,

I have an application with 177 radio buttons on a screen (Don't ask!). Is
there a simple want to excute a sub when any of them are checked.

Thanks,

Michael
Mar 15 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Michael Hesse wrote:
I have an application with 177 radio buttons on a screen (Don't
ask!). Is there a simple want to excute a sub when any of them are
checked.


You could make your own radio button class that inherits from the standard
radio button and add a static event to the definition. Then, override the
onclick method, call the base method, and raise the event. you can then
handle this event like any other from your code.
Mar 15 '06 #2

P: n/a
Great suggestion. Thanks!

Michael
"Leon Mayne" <no****@nospam.com> wrote in message
news:ul**************@tk2msftngp13.phx.gbl...
Michael Hesse wrote:
I have an application with 177 radio buttons on a screen (Don't
ask!). Is there a simple want to excute a sub when any of them are
checked.


You could make your own radio button class that inherits from the standard
radio button and add a static event to the definition. Then, override the
onclick method, call the base method, and raise the event. you can then
handle this event like any other from your code.

Mar 15 '06 #3

P: n/a
Hello, Michael,

Perhaps you could iterate through the controls on your form, and for
those that are radio buttons, use AddHandler to assign the same routine
as the CheckedChanged handler for all of them. Something like:

Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
For Each ctl As Control In Me.Controls
If (TypeOf ctl Is RadioButton) Then
Dim rbt As RadioButton = DirectCast(ctl, RadioButton)
AddHandler rbt.CheckedChanged, _
AddressOf Common_CheckedChanged
End If
Next
End Sub

Private Sub Common_CheckedChanged(ByVal sender As Object, _
ByVal e As System.EventArgs)
Dim rbtSender As RadioButton = DirectCast(sender, RadioButton)
MsgBox(rbtSender.Name & " is now " & rbtSender.Checked)
End Sub

Cheers,
Randy
Michael Hesse wrote:
Hi,

I have an application with 177 radio buttons on a screen (Don't ask!). Is
there a simple want to excute a sub when any of them are checked.

Thanks,

Michael

Mar 16 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.