private void DebugWriteAllControls(Control startControl, int depth)
{
System.Diagnostics.Debug.WriteLine("Depth: " + String.Format("{0:D3}", depth) + " Cntrl: " + startControl.ID);
if (startControl.Controls != null)
{
int ControlCount = startControl.Controls.Count;
for (int x = 0; x < ControlCount; x++)
{
DebugWriteAllControls(startControl.Controls[x], depth + 1);
}
}
}
The function can be called from any control and will iterate through all child controls while outputing their information to the output window in Visual Studio.