A Pop-Up Menu

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!
jonnyfunfunAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

iboutchkineCommented:
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
        ContextMenu1.MenuItems.Clear()
        Dim myMenuItem As MenuItem

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

        myMenuItem = New MenuItem("Option2")
        ContextMenu1.MenuItems.Add(myMenuItem)
        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


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
davidrichardsonCommented:
0
jonnyfunfunAuthor Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Internet Marketing

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.