add control set programmatically

I have a popupmenu. When the user clicks a button I want to display as second (and third etc.) popupmenu which is a member of a control set, actually a clone of the first popupmenu, but with different index.

I made the first popupmenu already a controlset with index 0
How to add more controls in this set?


Quick test:

dim apopup as PopupMenu linkMenu.Append(aPopup) <- compiler error linkmenu(1).Top = linkMenu(0).top + 30 linkmenu(1).Left = linkMenu(0).Left

If your control set is called linkMenu then you can do:

dim lm as new linkMenu = linkMenu(0).top + 30 lm.left = linkMenu(0).left

You need to create a new instance:

dim apopup as PopupMenu = New PopupMenu1   // <--- put the name of your PopupMenu with the index 0 here

Jason’s solution worked for me! Thanks.

Ehmmmm … hold on…

[code] dim lm as new linkMenu = linkMenu(linkmenu.ubound).top + 30 <— compiler error (does not exist)
lm.left = linkMenu(0).left[/code]

Why can’t I get linkmenu.ubound?

It’s not a true array. You will need to store the “ubound” in a static or window variable which will be incremented every time a new popupmenu is added to the control set.

Quick example:

Ok Jason thanks very much!