trival:
// find all child controls named "A"
Control[] list = ControlWalker(myControl, delegate(Control ctl)
{
return ctl.ID != null && ctl.ID == "A";
});
......
// control walker method
public delegate bool ControlWalkerMatcher (Control ctl);
public Control[] ControlWalker(
Control ctl,
ControlWalkerMatcher matcher)
{
ArrayList list = new ArrayList();
if (matcher(ctl)) list.Add(ctl);
for (int i=0; i < ctl.Controls.Count; ++i)
{
Control[] childList =ControlWalker(ctl.Controls[i],matcher);
if (childList.Length 0) list.AddRange(childList);
}
return (Control[]) list.ToArray(typeof(Control));
}
-- bruce (sqlwork.com)
shapper wrote:
Hello,
I have a control named Parent in my page.
Parent has many child controls under it which also have other child
controls under them.
I need to find a control named "A" which i don't know exactly where it
is.
I just know that is under parent or under any of Parent Child
controls ...
How can I do this?
Thanks,
Miguel