using GroupBox control with radio buttons - get selected value?

G

Guest

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
 
M

Mattias Sjögren

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top