Let's say I have 7 group boxes but some of them also have group box inside them and some do not. now if I want to iterate through those 7 group boxes and apply something to them, is there a way that I can exclude those Child group boxes from this loop?
thanks, so there is not such a thing like a "parent" or so property that I can check on each of them? right?
BDotA
2010-09-09 20:41:50
not that I'm aware of, but it could be associated with a container or hwnd property
Beth
2010-09-09 20:57:27
+1
A:
though i question the choice of implementation (can you use polymorphism instead? what exactly are you trying to do?), there is a Parent property, e.g.
void soSomething(Control ctrl)
{
if (ctrl is GroupBox && (ctrl.Parent is null || !(ctrl.Parent is GroupBox)))
{
//do something here
}
foreach(Control child in ctrl.Controls)
{
doSomething(child);
}
}
Steven A. Lowe
2010-09-09 20:51:40