On 20/09/2005 DraguVaso wrote:
Hi,
Is there actually a way to get ALL the Controls on a Form? While
using the ControlCollection, it only returns the Controls that are
directly on the Form, not the controls that are on a
(TableLayout)Panel etc.
You could use a recursive procedure.
private sub GetControls(Control ctlParent, ref ArrayList al)
{
al.Add(ctlParent);
foreach(Control ctlChild in ctlParent)
GetControls(ctlChild, ref al);
}
Not tested, my development PC is off at the moment but something like
that should do it. Call it by setting up a new ArrayList and starting
with the Windows Form. If it doesn't recognise the Form as a control
you would need to start with:
private sub GetAllControls()
{
ArrayList al = new ArrayList();
foreach(Control ctl in frmMain)
GetControls(ctl, ref al);
}
--
Jeff Gaines