I\'d like to add an event to all TextBoxes on my Form:
Form
foreach (Control C in this.Controls) { if (C.GetType() == typeof(System.Windows.Forms
Try this
AllSubControls(this).OfType().ToList() .ForEach(o => o.TextChanged += C_TextChanged);
where AllSubControls is
private static IEnumerable AllSubControls(Control control) => Enumerable.Repeat(control, 1) .Union(control.Controls.OfType() .SelectMany(AllSubControls) );
LINQ is great!