Created
September 22, 2019 22:44
-
-
Save tjone270/8f3460435bd33f97c9192e55993b423c to your computer and use it in GitHub Desktop.
Get all WinForms controls on a form.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private IEnumerable<Control> GetAllControls(Control.ControlCollection controls) { | |
List<Control> all_controls = new List<Control>(); | |
foreach (Control control in controls) { | |
if (control.GetType() == typeof(GroupBox)) { | |
all_controls.AddRange(GetAllControls(control.Controls)); | |
} | |
all_controls.Add(control); | |
} | |
return all_controls; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment