Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / IEnumerable

Findcontrol using a non recursive approach

3.00/5 (4 votes)
9 Feb 2012CPOL 40.6K  
C#
public static List<control> FindControls( Control controlTop )
{
    List<control> list = new List<control>();

    list.Add(controlTop);

    for (int i = 0; i < list.Count; ++i)
    {
        list.AddRange(list[i].Controls);
    }

    return list;
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)