Skip to content

Instantly share code, notes, and snippets.

@dunston
Created September 11, 2014 08:56
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 dunston/5bf73050b102933060ba to your computer and use it in GitHub Desktop.
Save dunston/5bf73050b102933060ba to your computer and use it in GitHub Desktop.
Finding all sub controls
// You maybe has to call EnsureChildControls first
public static Control[] FlattenHierachy(Control root)
{
List<Control> list = new List<Control>();
list.Add(root);
if (root.HasControls())
{
foreach (Control control in root.Controls)
{
list.AddRange(FlattenHierachy(control));
}
}
return list.ToArray();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment