<"Thonglao Rud" <>> wrote:
I'm trying to clear all textbox on the form.
foreach (Control c in this.Controls)
{
//if (c.GetType() == typeof(TextBox))
if (c is TextBox)
{
// Found it
c.Text = "";
MessageBox.Show(c.Name.ToString());
}
}
However, this code can not effect with TextBox that inside groupbox in my form.
What is wrong?
Well, the TextBox in a GroupBox isn't directly inside your form - so
you should call the same method recursively for any container control.
It's probably easiest to actually call it recursively for *all*
controls, seeing as the Controls property is inherited from Control
itself, but that may well not be the most efficient way.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too