Click here to Skip to main content
15,441,078 members
Articles / Ienumerable
Posted 17 Oct 2011


3 bookmarked

Findcontrol using a non recursive approach

Rate me:
Please Sign up or sign in to vote.
3.00/5 (4 votes)
9 Feb 2012CPOL
public static List<control> FindControls( Control controlTop )
    List<control> list = new List<control>();


    for (int i = 0; i < list.Count; ++i)

    return list;


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

Written By
Software Developer (Senior)
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

Generalcannot convert from 'System.Web.UI.ControlCollection' to 'Sy... Pin
Member 38257110-Feb-12 2:12
MemberMember 38257110-Feb-12 2:12 
GeneralReason for my vote of 5 Perfect if you don't care whether yo... Pin
PopeDarren21-Dec-11 4:49
MemberPopeDarren21-Dec-11 4:49 
GeneralGetSubControls where is code. I am new to .net Pin
Janak Desai8-Nov-11 5:12
MemberJanak Desai8-Nov-11 5:12 
GeneralRe: The code has undergone several revisions and optimizations. ... Pin
Kabwla.Phone27-Nov-11 23:56
MemberKabwla.Phone27-Nov-11 23:56 
The code has undergone several revisions and optimizations.
The original code made by rj45 used an additional function named 'GetSubControls'. The latest revision of the code, (from my hand, for which rj45 is yet still to credit or thank me) no longer needs this function.

Check out Alternative1 which gives you the option to go dept-first or width first, depending on your needs.
GeneralReason for my vote of 1 You've just looped through first lay... Pin
Hasheminezhad7-Nov-11 18:55
MemberHasheminezhad7-Nov-11 18:55 
GeneralReason for my vote of 1 Failure to provide credits to Kabwla... Pin
Kabwla.Phone7-Nov-11 3:44
MemberKabwla.Phone7-Nov-11 3:44 
Generalhah nice! Pin
rj451-Nov-11 8:12
Memberrj451-Nov-11 8:12 
GeneralReason for my vote of 2 For unprofessional usage of language Pin
Kabwla.Phone1-Nov-11 1:59
MemberKabwla.Phone1-Nov-11 1:59 
GeneralReason for my vote of 1 I don't understand this. It adds a ... Pin
jim lahey18-Oct-11 2:31
Memberjim lahey18-Oct-11 2:31 
GeneralRe: I suggest you try it out. I hint may be that it wouldn't wo... Pin
rj4518-Oct-11 9:48
Memberrj4518-Oct-11 9:48 
GeneralRe: Did you get a chance to try it, I'd appreciate it if you cou... Pin
rj4524-Oct-11 9:15
Memberrj4524-Oct-11 9:15 
GeneralRe: See Alternative 1 to see why it works. (with too much code) Pin
Kabwla.Phone1-Nov-11 2:32
MemberKabwla.Phone1-Nov-11 2:32 
QuestionNeed more code Pin
Tridip Bhattacharjee17-Oct-11 20:17
professionalTridip Bhattacharjee17-Oct-11 20:17 
AnswerRe: Need more code Pin
rj4518-Oct-11 10:17
Memberrj4518-Oct-11 10:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.