Itterate controls in Container Control

XOJO 2021r1.1 - Windows 10 Desktop

I try to itterate all the controls in a Container Control to make them all Invisible , except for a few they need to stay visible.
I can put all the controls with a property visible = False, but I like to do it with a itteration.
Is this possible ?
This is the code that i tried, but I cannot find the way to make some controls not visible.
The Case “names” will have no action
The case Else should make the control invisible

Var i As Integer

For i = 0 To Self.ControlCount - 1
Select Case Self.Control(i).Name
Case “Name1”, “Name2”, “Name3”
’ Keep these visible
Case Else
’ Set all the other controls.Visible = False
End Select
Next

Regards

may be you can get the name using introspection ?

You need to use a workaround which is nicely described here: EmbeddedWindowControl – Writings from the sticks

not sure because the OP is already in the containercontrol, and is iterating the controls INSIDE the CC.
the link you gave is for getting CC inside a window, using controls() array.

Control does not have a visible property. RectControl does. Self.Control(i) returns a Control. You need to cast it to a RectControl to access the Visible property.

For i = 0 to Self.ControlCount - 1
   if Self.Control(i) IsA RectControl then
      Select Case Self.Control(i).Name
      Case "Name1", "Name2", "Name3"
         RectControl(Self.Control(i)).Visible = True
      Else
         RectControl(Self.Control(i)).Visible = False
      End Select
   End If
Next
3 Likes

Thanks to all for the replies.
The soluton from Tim Hare works perfect. Thanks a lot.

Regards
Etienne