Click here to Skip to main content
11,428,004 members (60,135 online)
Click here to Skip to main content

Findcontrol using a non recursive approach

, 9 Feb 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
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)

Share

About the Author

rj45
Software Developer (Senior)
Canada Canada
No Biography provided

Comments and Discussions

 
Generalcannot convert from 'System.Web.UI.ControlCollection' to 'Sy... Pin
Member 38257110-Feb-12 3:12
memberMember 38257110-Feb-12 3:12 
GeneralReason for my vote of 5 Perfect if you don't care whether yo... Pin
PopeDarren21-Dec-11 5:49
memberPopeDarren21-Dec-11 5:49 
GeneralGetSubControls where is code. I am new to .net Pin
Janak Desai8-Nov-11 6:12
memberJanak Desai8-Nov-11 6:12 
GeneralRe: The code has undergone several revisions and optimizations. ... Pin
Kabwla.Phone28-Nov-11 0:56
memberKabwla.Phone28-Nov-11 0:56 
GeneralReason for my vote of 1 You've just looped through first lay... Pin
Hasheminezhad7-Nov-11 19:55
memberHasheminezhad7-Nov-11 19:55 
GeneralReason for my vote of 1 Failure to provide credits to Kabwla... Pin
Kabwla.Phone7-Nov-11 4:44
memberKabwla.Phone7-Nov-11 4:44 
Generalhah nice! Pin
rj451-Nov-11 9:12
memberrj451-Nov-11 9:12 
GeneralReason for my vote of 2 For unprofessional usage of language Pin
Kabwla.Phone1-Nov-11 2:59
memberKabwla.Phone1-Nov-11 2:59 
GeneralReason for my vote of 1 I don't understand this. It adds a ... Pin
jim lahey18-Oct-11 3:31
memberjim lahey18-Oct-11 3:31 
GeneralRe: I suggest you try it out. I hint may be that it wouldn't wo... Pin
rj4518-Oct-11 10:48
memberrj4518-Oct-11 10:48 
GeneralRe: Did you get a chance to try it, I'd appreciate it if you cou... Pin
rj4524-Oct-11 10:15
memberrj4524-Oct-11 10:15 
GeneralRe: See Alternative 1 to see why it works. (with too much code) Pin
Kabwla.Phone1-Nov-11 3:32
memberKabwla.Phone1-Nov-11 3:32 
QuestionNeed more code Pin
Tridip Bhattacharjee17-Oct-11 21:17
memberTridip Bhattacharjee17-Oct-11 21:17 
AnswerRe: Need more code Pin
rj4518-Oct-11 11:17
memberrj4518-Oct-11 11:17 
Export whole page to Excel with infragistics in ASP.NET C#[^]

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150428.2 | Last Updated 9 Feb 2012
Article Copyright 2011 by rj45
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid