C# WinForms - What order are controls added to control collection?
Posted on 2006-11-02
I have a C# WinFroms Application with the following code:
for (int i = 0; i < this.Controls.Count; i++)
if (this.Controls[i] is ListBox)
Control newCtrl = this.Controls[i];
ListBox lb = (ListBox)newCtrl;
When I step through the code, the controls do not seem to be in any particular order within the collection. In order for my code to work correctly, I need to clear certain listboxes, before clearing other listboxes. Is there a way to designate what order the controls are put into the collection?