Move multiple controls

Hi everyone !

I want to know how to change the position (x and y) of all the ‘Popupmenu’ when my application starts (open event).

In fact, how to change the position of all my ‘Popupmenu’ without specifying their names ?

Thanks for your help…

Steph

The window exposes a method called, Control(), and a property, ControlCount. You loop from zero to ControlCount-1 and examine each control using the IsA operator to determine if it is a PopupMenu. If so, you change it’s position.

for i = 0 to ControlCount-1
   if Control(i) IsA PopupMenu then
      PopupMenu(Control(i)).Top = PopupMenu(Control(i)).Top + 10
   end
next

Note: the notation PopupMenu(Control(i)) is called Casting. It basically tells the compiler to take Control(i) and treat it like a PopupMenu. You would get a runtime exception if Control(i) were not actually a PopupMenu, but we have already confirmed (via IsA) that it is.

Great ! This works perfectly !

Many thanks for the explanation, Tim :slight_smile:

Best regards

Steph

[quote=178545:@Tim Hare]The window exposes a method called, Control(), and a property, ControlCount. You loop from zero to ControlCount-1 and examine each control using the IsA operator to determine if it is a PopupMenu. If so, you change it’s position.

for i = 0 to ControlCount-1
   if Control(i) IsA PopupMenu then
      PopupMenu(Control(i)).Top = PopupMenu(Control(i)).Top + 10
   end
next

Note: the notation PopupMenu(Control(i)) is called Casting. It basically tells the compiler to take Control(i) and treat it like a PopupMenu. You would get a runtime exception if Control(i) were not actually a PopupMenu, but we have already confirmed (via IsA) that it is.[/quote]

Wow, beautiful post, Tim.