score:-1

may be this will help you...

How can I get all controls from a Form Including controls in any container?

once you have the list you can query'em

score:3

Something like this should work (not perfect code by any means...just meant to get the idea across):

public IEnumerable<Control> GetSelfAndChildrenRecursive(Control parent)
{
    List<Control> controls = new List<Control>();

    foreach(Control child in parent.Controls)
    {
        controls.AddRange(GetSelfAndChildrenRecursive(child));
    }

    controls.Add(parent);

    return controls;
}

var result = GetSelfAndChildrenRecursive(topLevelControl)
    .Where(c => c is TextBox || c is Checkbox);

Related Articles