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

using GroupBox control with radio buttons - get selected value?

P: n/a
Hello,

If I place a groupbox control (gb1) on a form and add 2 radion buttons where
rad1 represents a value of 1 of rad2 a value of 2 --- when I click on rad1 I
want a messagebox to show the value "1", when I click rad2 a messagebox shows
the value "2". Yes, in the click event of each radio button this is no
sweat. But I thought there was a way to consolidate that by using an event
in the groupbox: Here is my Pseudo Code

Private sub gb1_click(...) handles gb1
If rad1.Checked.Equals(True) Then MessageBox.Show("1")
If rad2.Checked.Equals(True) The MessageBox.Show("2")
End Sub

Is something like this doable? How to do it? My sample above doesn't work.

When I click on rad1, rad2 becomes unchecked. When I click on rad2, rad1
becomes unchecked. So that part is working correctly. How to retrieve the
desired value from gb1?

Thanks,
Rich
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Is something like this doable? How to do it? My sample above doesn't work.


Sure, a method can handle multiple events. Try it like this

Private Sub RadioClickHandler(sender As Object, e As EventArgs)
Handles rad1.Click, rad2.Click
Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 21 '05 #2

P: n/a
Thanks. I believe that is what I was looking for.

Rich

"Mattias Sjögren" wrote:
Is something like this doable? How to do it? My sample above doesn't work.


Sure, a method can handle multiple events. Try it like this

Private Sub RadioClickHandler(sender As Object, e As EventArgs)
Handles rad1.Click, rad2.Click
Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.