views:

55

answers:

1

I have a winforms app with a group box called priceClassGroupBox. Inside it I dynamically add RadioButtons to which I give a name, say radio1, radio2, radio3.

I have 2 questions:

  1. Can I automatically select a given RadioButton by it's name without iterating through each control?
  2. Can I get the name of the selected RadioButton without iterating through each control?
A: 
  1. Yes you can call Controls.Find

eg

RadioButton rdo = (RadioButton)priceClassGroupBox.Controls.Find("radio1", false);

2 . No you would have to iterate through and find the selected radio button

w69rdy