Iterating through Controls on A Form
-
Hi There.... I am looking to iterate through A form's Controls collection. However i am also interested in control which are the child of panels. Is there any built support in WinForms? Or is the solution just to write my own little recursive method? Thanks in advance Aj
-
Hi There.... I am looking to iterate through A form's Controls collection. However i am also interested in control which are the child of panels. Is there any built support in WinForms? Or is the solution just to write my own little recursive method? Thanks in advance Aj
Hi, yes recursion is the way to go:
private void LoopThroughControls(Control c) {
foreach (Control subControl in c) {
//do something with cLoopThroughControls(c);
}
}Within your Form just call:
LoopThroughControls(this);
Robert -
Hi, yes recursion is the way to go:
private void LoopThroughControls(Control c) {
foreach (Control subControl in c) {
//do something with cLoopThroughControls(c);
}
}Within your Form just call:
LoopThroughControls(this);
Robert -
Hi, yes recursion is the way to go:
private void LoopThroughControls(Control c) {
foreach (Control subControl in c) {
//do something with cLoopThroughControls(c);
}
}Within your Form just call:
LoopThroughControls(this);
Robert -
private void button3_Click(object sender, EventArgs e) { treeView1.Nodes.Add(LoopThroughControls(this)); } private TreeNode LoopThroughControls(Control c) { TreeNode node = new TreeNode(c.Name); Control ctemp; for(int i=0;iOk ...
What exactly are you trying to tell me with this? Robert