7
Answers

What is the problem of clearing the text box?

Joe Wilson

Joe Wilson

10y
1.2k
1
My code:
 
private void clearToolStripMenuItem_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);
}
}

Answers (7)