Click to See Complete Forum and Search --> : Pull down Menu
pueromane
December 20th, 1999, 06:56 AM
I have written an program witch has a pull down menu. I want to make at run time new etries in the pull down menu. At the moment I have 10 etries witch are hidden. When I want to make a new one, I set it to not hidden. But with this methode I can only add 10 new entries.
How can I add more entries. Is there an add methode or any other methode witch I can use.
mfG Pueromane
Jean Spector
December 20th, 1999, 09:12 AM
If you define menu as an array (in menu editor change Index field to something other than zero) you can add/remove additional menu items with Load/Unload
Jean Spector
Tech Support Team Leader, CET
mage@lycosmail.com
(in VB from 11/1999)
pueromane
December 20th, 1999, 12:18 PM
I have an array but how can I use the Load/Unload functions. Can you give me an example.
mfG Puermane
Chris Eastwood
December 20th, 1999, 03:54 PM
Here's a quick example - take a new project and to Form1, add a menu (mnuFile), then add a menu item below it called mnuItem with an index of 0.
Dim lCount as Long
for lCount = 1 to 10
Load mnuItem(lCount)
mnuItem(lCount).Caption = "Menu item " & lCount
mnuItem(lCount).Visible = true
next
You can now check which menu item was clicked in the mnuItem_Click event :
private Sub mnuItem_Click(Index as Integer)
MsgBox "Menu " & mnuItem(Index).Caption & " clicked"
End Sub
- of course, you might want to place something in the 'tag' property of each menu item to identify them a little better.
The 'Unload' function simply removes the items at runtime :
Dim lCount as Long
for lCount = 10 to 1 step -1
Unload mnuItem(lCount)
next
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb
pueromane
December 21st, 1999, 04:37 AM
thanks Chris.
It works great. That's the thing I was searching for.
mfG Pueromane
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.