|
-
Feb 11th, 2005, 02:24 PM
#1
Thread Starter
Fanatic Member
Looping through controls
Hello,
I have this code that works for checking just one RadioButton to see if it is checked when looping through a group of RadioButtons. How can I check ALL of the RadioButtons?
VB Code:
foreach(Control EnumControl in this.Frame1.Controls)
{
if (EnumControl.GetType().Equals(typeof(RadioButton)))
{
if (optCommand0.Checked == true) //What do I do here to check ALL RadioButtons?
{
MessageBox.Show("I'm Here");
break;
}
}
}
-
Feb 11th, 2005, 02:30 PM
#2
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;
}
}
}
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Feb 11th, 2005, 02:37 PM
#3
Thread Starter
Fanatic Member
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 .
-
Feb 11th, 2005, 04:16 PM
#4
Thread Starter
Fanatic Member
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);
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|