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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating runtime menu item

Status
Not open for further replies.

MJI111

MIS
Jul 9, 2005
11
NG
Pls how do i create menu items at runtime. I want some menu option to be dynamically created based on the values in my database. Pls how do I
 
In the Menu Editor, set whatever top level Menu item's Index to 0. Now in your code, to add a menu item use Load, to remove an item use Unload.

Maybe this world is another planet’s Hell.
Aldous Huxley
 
You must create an array of menu items. In i.e. menu "file" insert an item with:
name: mnudyn
caption: leave it blank
index: 0
and not visible

Do this for e.g 10 items with the same above characteristics, changing (increasing) only the index. So the 10th item will have index:9


...
 
Hello bigtimmin, thanks for the quick response. I cant find the load method in the menu object. How do i load it. what is the construct
 
Hello vBakias, i thank you for your suggestion but i will run out of array if i had to create menu items more than 10. I dont know how menu items will be created. it all depends on what i pick from my database where the menu items are set
 
Say in Menu Editor you have a menu item named 'mnuItem', you set the Index to 0. (This makes the 'mnuItem' control an array) Click OK! Now somewhere in your code, to add a new menu item.
Code:
Dim i as Integer
i = UBound(mnuItem) + 1
Load mnuItem(i)
mnuItem(i).caption = "[i]NewMenuItemCaption[/i]"

Maybe this world is another planet’s Hell.
Aldous Huxley

 
Bigtimmin, Thanks a billion times. it works though with little modification. The second line should have read

i= mnuItem.UBound+1

 
Bigtimmin, Thanks a billion times. it works though with little modification. The second line should have read

i= mnuItem.UBound+1

in VB.NET maybe... It is correct for VB6

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Actually both will work in VB.6, UBound(mnuItem) and mnuItem.UBound.

Maybe this world is another planet’s Hell.
Aldous Huxley

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top