Link to home
Start Free TrialLog in
Avatar of avromy
avromy

asked on

Dynamic Menus

How do I dynamically add menus AND sub menus at run time?
Avatar of shchuka
shchuka

I'm not sure about the submenus, but adding menus is easy.

Create a new top-level menu, say "New menu" in the menu designer and add one menu under this top-level, call it mnuDynamic and set its index property to 0, visible to false and leave caption blank.

Now in run time:
    ' This will create the first item under this New Menu top-level with caption Menu 1
    load mnuDynamic(0)
    mnuDynamic(0).caption = "Menu 1"
    mnuDynamic(0).visible = true

    ' This will create the second item under this New Menu top-level with caption Menu 2
    load mnuDynamic(1)
    mnuDynamic(1).caption = "Menu 2"
    mnuDynamic(1).visible = true

And so on...

Avatar of avromy

ASKER

I had been aware of how to create a main menu at run time.  That is why I stressed AND A SUBMENU.  
If any one knows of a third party menu control, that would also be helpful.  I looked at a control called ActiveBar, but that does so much more than I need, and thus seems quite complicated.
I think you need to set the Parent property on the menu you're making (mnuDynamic in your example).

Make the Parent an object reference to the item in the main menu, that this submenu will appear from.


Avatar of avromy

ASKER

bernfarr,
   When trying to set the parent property, I get "Invalid Use of Property."

Thanks,
       Alan
ASKER CERTIFIED SOLUTION
Avatar of waty
waty
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial