How do I go about looping through all the controls within a container, and all the controls in the container of a containing control, and so on.
Form
-Panel
--Control
--Tab
----Control
----Control
--Tab
----Control
The following only retrieves -Panel and none of the other controls
For Each cntrl As Control In Me.Controls
Next
How can I retrieve them all in a For Each loop without an If/Then for every level in the stack?
EDIT:
Dim ctl As Control = Me
Do
ctl = Me.GetNextControl(ctl, True)
'Do whatever you have to ctl
Loop Until ctl Is Nothing
This is so far the best method I found of doing this.
You have to define a method that
recursivelytraverse containers inside the container. Something like this:To call this method: