ralphtrent
Programmer
Hi
I have a form. When I press a button, I am going through all the controls in the form and seeing if it is a radio button
What I need to do is determine if the rb is checked, but since rb is being declared as a control, I can not do that since Control does not have a Checked Property. If I declare rb as a RadioButton first like thisk
Two things happen, one the if statements is invalid because rb will always be a RadioButton and two it will error out when it comes accross a control that is not a radiobutton.
Any idea's?
Thanks,
RT
I have a form. When I press a button, I am going through all the controls in the form and seeing if it is a radio button
Code:
foreach (Control rb in gbOptions.Controls)
{
if (rb is RadioButton)
{
Console.WriteLine(rb.Name);
}
}
What I need to do is determine if the rb is checked, but since rb is being declared as a control, I can not do that since Control does not have a Checked Property. If I declare rb as a RadioButton first like thisk
Code:
foreach (RadioButton rb in gbOptions.Controls)
{
if (rb is RadioButton)
{
Console.WriteLine(rb.Name);
}
}
Two things happen, one the if statements is invalid because rb will always be a RadioButton and two it will error out when it comes accross a control that is not a radiobutton.
Any idea's?
Thanks,
RT