Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Building menus and sub-menus at runtime 1

Status
Not open for further replies.

Glasgow

IS-IT--Management
Jul 30, 2001
1,669
GB
I am using a control array to dynamically build a drop-down menu at run-time. However, some menu items will themselves have further drop-down sub-menus associated with them. How can I build the sub-menus and associate these with options in the main menu. For example:

Menu option 1: Fred
Menu option 2: Nancy
Menu option 3: Fred & Nancy's Children
Sub-menu option 3.1: Sarah
Sub-menu option 3.2: Johnnie
Sub-menu option 3.3: Laura
Menu option 4: Andy
Menu option 5: Scott

I can easily build a menu with the 5 main options but cannot find a way to build in the sub-menu of children's names.

Any help would be greatly appreciated.
 
Are you talking about a menu on the tool bar or a drop down menu box? If it's the tool bar menu you just use the submenu command. If it's a drop down box then you will have to add another drop down box and populate it depending on the selection made in the first one.
Todd Norris
Hope this helps !
 
Thanks for the suggestions, Todd. My ultimate goal was to use the Menu Editor to create a menu on an MDI form with one drop down option then add to those options at runtime and use the PopUpMenu method to display the menu. However, I also wanted to be able to generate a further nested sub-menu level within the same menu control array but at a different level - i.e. achieving the equivalent to a simple indent in the menu editor. However, I can see no way of controlling the menu option's level within code.

With regard to the submenu command to which you refer, is this an API call rather than standard VB?

I have now attempted to implement a version of your second suggestion and effectively introduced a second menu control which I hope to activate when certain options on the first menu are triggered. However, this is causing some further problems as I am attempting to trigger the display of one menu within the click event of another but, as only one PopUpMenu can be visible at a time, my second menu is being ignored.

Stuart
 
U could use API functions for menus to add a submenu to an existing menu or to add new menu... ________

George
 
Thanks George. I may well resort to API if all else fails.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top