A Pop-Up Menu

Posted on 2004-11-19
Medium Priority
Last Modified: 2013-11-28
Hi!  I have a program with a system tray icon (using the tray notification control that Microshaft has) and I want to make it so when the user right clicks on it, they get a pop up menu.  Sort of like the pop up menu you could get with the popupmenu() command in VB6.  How do I do this in VB.net?  Thanks!
Question by:jonnyfunfun
LVL 28

Accepted Solution

iboutchkine earned 1000 total points
ID: 12628373
Add Icon to the NitifyIcon.
Add a ContextMenu to your form and set the ContextMenu property of your NotifyIcon to it.  
Then, in the Popup event of your ContextMenu, you can dynamically create the MenuItems as shown below.
  You can trap which menu item was selected using an old school select case based on the menuitem text:

   Private Sub ContextMenu1_Popup(ByVal sender As Object, ByVal e As System.EventArgs) Handles ContextMenu1.Popup
        Dim myMenuItem As MenuItem

        myMenuItem = New MenuItem("Option1")
        AddHandler myMenuItem.Click, AddressOf mmi_Click

        myMenuItem = New MenuItem("Option2")
        AddHandler myMenuItem.Click, AddressOf mmi_Click
    End Sub

    Private Sub mmi_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim mmi As MenuItem
        mmi = CType(sender, MenuItem)
        Select Case mmi.Text
            Case "Option1"
                MsgBox("Option1 is selected")
            Case "Option2"
                MsgBox("Option1 is selected")
        End Select
    End Sub


Expert Comment

ID: 12628437

Author Comment

ID: 12630501
Thanks for the answer!  

I need to get used to this whole VB.net stuff...I loved 6, but this .net stuff is so much different

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is a massive demand for content on the web right now, and it doesn't look like it's going to stop any time soon. But, if you are running a business blog, it's not just enough to offer your audience lots of content. It needs to be high-quality…
Over time, the online landscape has altered considerably, but that’s nothing compared to the up-and-coming trends that will shape the web design industry in the coming year. Keep reading to find out which trends will shape B2B web design in 2018.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question