1
Reply

How to know which RadioButton that is selected?

Tomas Westerlund

Tomas Westerlund

Aug 24 2011 4:28 AM
1.4k
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)