Max length for a textbox input value can be decided from the MaxLength property. But we need to do this for each textbox one by one.
Is there any way to set the value of MaxLength property once for all textboxes on a form?
Did it with recursive calls because Form have panels and textboxes are inside panels.
Here is the extension method to get all TextBoxes on a Form:
public static IEnumerable<TControl> GetChildControls<TControl>(this Control control) where TControl : Control
{
var children = (control.Controls != null) ? control.Controls.OfType<TControl>() : Enumerable.Empty<TControl>();
return children.SelectMany(c => GetChildControls<TControl>(c)).Concat(children);
}