using GroupBox control with radio buttons - get selected value?

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top