I have a group box contains radio buttons eg.
o Male
o Female
i want my code to get the sel
Windows Forms
For cases where there are multiple radio buttons to check, this function is very compact:
///
/// Get the value of the radio button that is checked.
///
/// The radio buttons to look through
/// The name of the radio button that is checked
public static string GetCheckedRadioButton(params RadioButton[] radioButtons)
{
// Look at each button, returning the text of the one that is checked.
foreach (RadioButton button in radioButtons)
{
if (button.Checked)
return button.Text;
}
return null;
}