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 Menu Items Dynamically

Status
Not open for further replies.

scasystems

Programmer
Jan 15, 2003
44
GB
How do you add items to an already existing menu via runtime. For instance I have created a mnuHistoryItem menu
at design time. When a Site is chosen I wish to :-

for i= 0 to mnuHistoryItem.ubound
if mnuHistoryItem(I).tag = site then exit for
next
if I > mnuHistoryItem.ubound then
'create item(I).caption = Site.Name
item(i).tag = Site.number
end if

Question is how do you extend the size of the menu
Tried redim preserve. Not sure how. All the books say you can do it but do not say how????

 
When you want to create a new menu item, do:

Load mnuHistoryItem(ubound(mnuHistoryItem)+1)
With mnuHistoryItem(ubound(mnuHistoryItem))
.Caption = Site.Name
.Visible = True
End With

- Andy
__________________________________
"On a clear disk you can seek forever"
 
Sussed It ->

for i= 0 to mnuHistoryItem.ubound
if mnuHistoryItem(I).tag = site then exit for
next
if I > mnuHistoryItem.ubound then
'create item(I).caption = Site.Name
Load mnuHistoryItem(I)
item(I).Caption = Site.name
item(i).tag = Site.number
end if
 
To Andy Groom.
Sorry Mate didn't see your reply before sending in solution.
Cheers for the fast response though
 
No problem. Remember that menu items loaded dynamically are invisible by default, it's easy to think it's not working but actually you can't see the menu item!


- Andy
__________________________________
"On a clear disk you can seek forever"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top