Author Topic: NotifyIcon -> subMenu  (Read 2556 times)

0 Members and 1 Guest are viewing this topic.

Ricky_76

  • Guest
NotifyIcon -> subMenu
« on: July 12, 2007, 10:53:13 AM »
-vb.net-

Hi,
I develop an application without UI.
When the application start, a notify icon appear in the system tray.
When I click on the icon a menu appear with some items on it!
I can't add submenu, usefull to group similar items.

ex:

-icon
       -About
       -Menu_1
                  -item 1
                  -item 2
                  -item 3
       -Menu_2
                  -item 1
                  -item 2
      -Help

Code: [Select]
    Friend WithEvents mnuContEsci As MenuItem
    Sub Main()
        Init()
        nfiIcona.Visible = True
        Application.Run()
    End Sub
    Private Sub Init()
        nfiIcona = New NotifyIcon()
        nfiIcona.Icon = New Icon("C:\Pippo.ico")
        nfiIcona.Text = "Margot"
        MenuContestuale = New ContextMenu()
        mnuContArcadia = New MenuItem()
        mnuContCommesse = New MenuItem()
        mnuRetrivePDF = New MenuItem()
        mnuContCorrispondenza = New MenuItem()
        mnuContCopertine = New MenuItem()
        mnuContMail = New MenuItem()
        mnuContSep0 = New MenuItem()
        mnuContSep1 = New MenuItem()
        mnuContEsci = New MenuItem()
        mnuContArcadia.Text = "Pippo"
        mnuContCommesse.Text = "Commesse"
        mnuContCorrispondenza.Text = "Corrispondenza"
        mnuRetrivePDF.Text = "RetrivePDF"
        mnuContCopertine.Text = "Copertine"
        mnuContMail.Text = "Mail"
        mnuContSep0.Text = "-"
        mnuContSep1.Text = "-"
        mnuContEsci.Text = "&Esci"
        MenuContestuale.MenuItems.AddRange(New MenuItem() {mnuContArcadia, mnuContSep0, mnuContCommesse, mnuRetrivePDF, mnuContCorrispondenza, mnuContCopertine, mnuContMail, mnuContSep1, mnuContEsci})
        nfiIcona.ContextMenu = MenuContestuale
    End Sub
    Public Sub mnuMenuContestuale(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuContArcadia.Click, mnuContCommesse.Click, mnuContCorrispondenza.Click, mnuContCopertine.Click, mnuRetrivePDF.Click, mnuContMail.Click, mnuContEsci.Click
        Select Case CType(sender, MenuItem).Text
            Case "Pippo"
                MsgBox("PIPPO")
            Case "Copertine"
                Covers.Show()
            Case "Commesse"
                CommesseNew.Show()
            Case "Corrispondenza"
                Corrispondenza.Show()
            Case "Mail"
                Corrispondenza.Show()
            Case "RetrivePDF"
                txt_serach.Show()
            Case "&Esci"
                nfiIcona.Visible = False
                Application.Exit()
        End Select
    End Sub

thx a lot
/r
« Last Edit: July 12, 2007, 11:01:52 AM by Ricky_76 »