Re: Looping through controls
Code:
foreach(Control EnumControl in this.Frame1.Controls)
{
if (EnumControl.GetType().Equals(typeof(RadioButton)))
{
if (optCommand0.Checked == true)
{
MessageBox.Show("I'm Here");
break;
}
}
}
Re: Looping through controls
My RadioButtons are:
optCommand0
optCommand1
optCommand2.
etc...
In other words, I have many and would like to know how to loop through them without having to list each one. Sort of like optCommand(i).checked .
Re: Looping through controls
//Loops through controls in a Frame. Finds "checked" RadioButton and displays it's name.
Code:
foreach(Control ctrl in Frame1.Controls)
{
if(ctrl.GetType() == typeof(RadioButton))
{
if(((RadioButton)ctrl).Checked == true)
{
MessageBox.Show(ctrl.name);
}
}
}