CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Pull down Menu

  1. #1
    Join Date
    Nov 1999
    Location
    Austria
    Posts
    53

    Pull down Menu

    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


  2. #2
    Join Date
    Dec 1999
    Location
    Tel Aviv, Israel, Earth, Solar System
    Posts
    50

    Re: Pull down Menu

    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
    [email protected]
    (in VB from 11/1999)

  3. #3
    Join Date
    Nov 1999
    Location
    Austria
    Posts
    53

    Re: Pull down Menu


    I have an array but how can I use the Load/Unload functions. Can you give me an example.

    mfG Puermane


  4. #4
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Pull down Menu

    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

  5. #5
    Join Date
    Nov 1999
    Location
    Austria
    Posts
    53

    Re: Pull down Menu

    thanks Chris.
    It works great. That's the thing I was searching for.

    mfG Pueromane


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured