First off I hope I'm putting this in the right place. Second I'm new to C-sharp so I'm learning as I go.
I'm using a groupbox with a series of radio buttons on it. I'm trying to determine which one is selected by trying to loop through the controls on the groupbox. I'm not having any luck with that. The only way I've been able to check them is to look at each one individually, there's got to be a better way. Any help would be appreciated, thanks.
GuyPosted Jan 23, 2008, 11:47 AM
AlanPosted Jan 23, 2008, 11:37 AM
I don't think there is in fact an easier way than to loop through the RadioButtons in the GroupBox. Something like this:
RadioButton checkedButton = null;
foreach(Control ctrl in groupBox1.Controls)
{
if (ctrl is RadioButton)
{
RadioButton rb = (RadioButton)ctrl;
if (rb.Checked)
{
checkedButton = rb;
break;
}
}
}