Joe Wilson

Joe Wilson

  • NA
  • 7.8k
  • 434.7k

What is the problem of clearing the text box?

Jun 30 2014 4:09 AM
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)