Skip to content

Instantly share code, notes, and snippets.

@hbiarge
Created November 8, 2010 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hbiarge/668234 to your computer and use it in GitHub Desktop.
Save hbiarge/668234 to your computer and use it in GitHub Desktop.
Enumerar controles formulario
public static IEnumerable<T> GetAllControls<T>(this Control @this) where T : Control
{
return @this.Controls.AsEnumerable()
.Where(x => x.GetType() == typeof(T))
.Select(y=>(T)y)
.Union(@this.Controls.AsEnumerable()
.SelectMany(x => GetAllControls<T>(x))
.Select(y=>(T)y));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment