Need help with Dynamic Menus


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Need help with Dynamic Menus

  1. #1
    Join Date
    Jun 2006
    Posts
    8

    Cool Need help with Dynamic Menus

    Hey all! Thanks for checking this out! I am writing a VB.Net app and I need to create a menu dynamically. I am creating the menu items from registry entries but I need some help with the event handlers, I have one sub that will work for all the menu item but I need to know which one was clicked so I can read the right registry key and carry out the action. Sounds simple but Iím stumped! Thanks in advance for any ideas, links, or hints. Some source code would be helpful to.

    Thanks
    Ryan

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    A MenuItem Click event handler receives a sender object as its first parameter. You can cast the sender to a MenuItem and read its Text or other property to decide what to do:
    Code:
    Private Sub MenuItem_Click(ByVal sender As System.Object, _ 
        ByVal e As System.EventArgs)
    
        Dim item As MenuItem = CType(sender, MenuItem)
        Select Case item.Text
            ' Take action based on menu captions
        End Select
    
    End Sub
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Jun 2006
    Posts
    8
    Thanks Phil,
    That worked great!

Similar Threads

  1. Dynamic Context Menus
    By No-e in forum .NET
    Replies: 2
    Last Post: 10-08-2005, 08:56 PM
  2. Dynamic Context Menus
    By No-e in forum .NET
    Replies: 1
    Last Post: 09-19-2005, 11:56 AM
  3. Dynamic menus dropping behind form elements
    By AshleyQuick in forum Web
    Replies: 0
    Last Post: 09-17-2001, 12:56 PM
  4. dynamic nested menus
    By Brad Taylor in forum VB Classic
    Replies: 16
    Last Post: 03-29-2001, 09:21 AM
  5. dynamic nested menus
    By Brad Taylor in forum VB Classic
    Replies: 0
    Last Post: 03-26-2001, 04:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center