Clear all TextBoxes

This loop function will clear all TextBoxes in your Form, wherever they are placed.
Comes in handy when creating a “Clear fields” button

[csharp]
private void button1_Click(object sender, EventArgs e)
{
RecursiveClearTextBoxes(this.Controls);
}

private void RecursiveClearTextBoxes(Control.ControlCollection cc)
{
foreach (Control ctrl in cc)
{
TextBox tb = ctrl as TextBox;
if (tb != null)
tb.Clear();
else
RecursiveClearTextBoxes(ctrl.Controls);
}
}
[/csharp]