How can i (programatically) get a list of all the controls in a given container? I have several containers (picturebox), each with many controls inside. How can i create the list of all the controls in each picturebox? Or how can I determine which container a given control is in?
All controls placed on a form are accesible via the Form's "Controls" collection, and each control has a "Container" property which returns a reference to its container
Code:
Dim ctl as Control
For Each ctl In Me.Controls
Debug.Print ctl.Name; ctl.Container.Name
Loop
To test for controls in a specific container, I'd use the ObjPtr function
Code:
Dim ctl as Control
For Each ctl In Me.Controls
If ObjPtr(SomePictureBox) = ObjPtr(ctl.Container) Then
Debug.Print ctl.Name; ctl.Container.Name
End If
Loop