Click here to Skip to main content
15,850,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want a menu while I am clicking the icon in system tray.

My code is:

public ContextMenu traymenu;

public Form()
           this.Resize += new EventHandler(Login_Resize);
private void Form_Load(object sender, EventArgs e)
           this.WindowState = FormWindowState.Minimized;
           this.Visible = false;
private void Login_Resize(object sender, EventArgs e)
            if (this.WindowState == FormWindowState.Minimized)
                this.ShowIcon = false;
                this.ShowInTaskbar = false;
                notifyIcon1.Visible = true;
                notifyIcon1.BalloonTipTitle = "Minimized to Start Menu Bar";
                notifyIcon1.BalloonTipText = " Chat App minimized"; 

                traymenu = new ContextMenu();
                traymenu.MenuItems.Add("Logout", OnExit);
            else if (FormWindowState.Normal == this.WindowState)
                notifyIcon1.Visible = false;
private void OnExit(object sender, EventArgs e)
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
         traymanu.Show();  // showing error in this line

solution need:
I need the contextmenu to be displayed while I am clicking the notify icon
Updated 11-Jun-13 20:20pm

1 solution

notifyIcon1.ContextMenu = trayMenu;

Put that in your constructor.
Share this answer
riodejenris14 12-Jun-13 2:15am    
it is not working!!!!
I need the menu when I clicked my notifyicon in system tray?
riodejenris14 12-Jun-13 2:45am    
thanx for rep I made a mistake ur code works fine!!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900