Click here to Skip to main content
15,949,686 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:

C#
public ContextMenu traymenu;

public Form()
       {
           InitializeComponent();
           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"; 
                notifyIcon1.ShowBalloonTip(15);

                traymenu = new ContextMenu();
                traymenu.MenuItems.Add("Logout", OnExit);
                this.Hide();
            }
            else if (FormWindowState.Normal == this.WindowState)
            {
                notifyIcon1.Visible = false;
            }
        }
private void OnExit(object sender, EventArgs e)
       {
           System.Environment.Exit(0);
       }
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
Posted
Updated 11-Jun-13 19:20pm
v2

1 solution

C#
notifyIcon1.ContextMenu = trayMenu;

Put that in your constructor.
 
Share this answer
 
v2
Comments
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