Fox,
Remember that you may have to descend into subgroups doing this. If you
have a groupbox on a form the textboxes inside it will be in its' controls
collection not the overall form's Controls collecton.
This will work although it hasn't been optimized
ArrayList boxes = new ArrayList(5);
foreach (Control c in this.Controls)
{
foreach (TextBox tb in GetTextBoxControls(c))
{
boxes.Add(tb);
}
}
private ArrayList GetTextBoxControls(Control c)
{
ArrayList x = new ArrayList(1);
if (c.Controls.Count > 0)
{
foreach (Control c1 in c.Controls)
{
ArrayList y = GetTextBoxControls(c1);
foreach (TextBox tmp in y)
{
x.Add(tmp);
}
}
}
else
{
if (c is TextBox)
{
x.Add(c);
}
}
return x;
}
Ron Allen
"Fox" <fox> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
Thank
"Adrian" <ma******@yahoo.com> wrote in message
news:ek**************@TK2MSFTNGP15.phx.gbl... foreach(Control c in this.Controls)
if (c is TextBox)
MessageBox.Show(c.Name);