How do I get available controls from a Windows Forms form using C#?
Try this method in your form. It will recursively get all controls on your form, and their children:
public static List GetControls(Control form)
{
var controlList = new List();
foreach (Control childControl in form.Controls)
{
// Recurse child controls.
controlList.AddRange(GetControls(childControl));
controlList.Add(childControl);
}
return controlList;
}
Then call it with a:
List availControls = GetControls(this);