How do I get available controls from a Windows Forms form using C#?
See Question&Answers more detail:osHow do I get available controls from a Windows Forms form using C#?
See Question&Answers more detail:osOr, ProfK's solution in enumerable syntax:
public static IEnumerable<Control> GetControls(Control form) {
foreach (Control childControl in form.Controls) { // Recurse child controls.
foreach (Control grandChild in GetControls(childControl)) {
yield return grandChild;
}
yield return childControl;
}
}