Tomas Westerlund

Tomas Westerlund

  • NA
  • 38
  • 32.5k

How to know which RadioButton that is selected?

Aug 24 2011 4:28 AM
Hi,
I am working on an assignment from the "Head First C#" book.

I have three radio buttons (joeRButton, bobRButton and alRButton).
I also has an array with an instance of an class named Guy. Every Guy (Joe, Bob and Al) has an instance of this class i.e. Guy[] guy = new Guy[3]. So far so good!

I want to know which radio button is checked when I press a button so I can do some stuff. However I don't want to do "if joeRButton.checked = true DO THIS, if bobRButton.checked = true DO THIS", I want it do be more dynamic.

Each radio button is assigned to their instance (guy[0] = new Guy() { Name = "Joe", Cash = 100, MyLabel = joeBox, MyRadioButton = joeRButton })

Can anyone help me with this?



Answers (1)