Click here to Skip to main content
Click here to Skip to main content

Findcontrol using a non recursive approach

By , 9 Feb 2012
 
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)

About the Author

rj45
Software Developer (Senior)
Canada Canada
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Generalcannot convert from 'System.Web.UI.ControlCollection' to 'Sy... PinmemberMember 38257110 Feb '12 - 2:12 
GeneralReason for my vote of 5 Perfect if you don't care whether yo... PinmemberPopeDarren21 Dec '11 - 4:49 
GeneralGetSubControls where is code. I am new to .net PinmemberJanak Desai8 Nov '11 - 5:12 
GeneralRe: The code has undergone several revisions and optimizations. ... PinmemberKabwla.Phone27 Nov '11 - 23:56 
GeneralReason for my vote of 1 You've just looped through first lay... PinmemberHasheminezhad7 Nov '11 - 18:55 
GeneralReason for my vote of 1 Failure to provide credits to Kabwla... PinmemberKabwla.Phone7 Nov '11 - 3:44 
Generalhah nice! Pinmemberrj451 Nov '11 - 8:12 
GeneralReason for my vote of 2 For unprofessional usage of language PinmemberKabwla.Phone1 Nov '11 - 1:59 
GeneralReason for my vote of 1 I don't understand this. It adds a ... Pinmemberjim lahey18 Oct '11 - 2:31 
GeneralRe: I suggest you try it out. I hint may be that it wouldn't wo... Pinmemberrj4518 Oct '11 - 9:48 
GeneralRe: Did you get a chance to try it, I'd appreciate it if you cou... Pinmemberrj4524 Oct '11 - 9:15 
GeneralRe: See Alternative 1 to see why it works. (with too much code) PinmemberKabwla.Phone1 Nov '11 - 2:32 
QuestionNeed more code PinmemberTridip Bhattacharjee17 Oct '11 - 20:17 
AnswerRe: Need more code Pinmemberrj4518 Oct '11 - 10:17 

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.

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