Click here to Skip to main content
Click here to Skip to main content

NotifyIcon in System Tray with Context Menu Using C#

, 5 Oct 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
This is a small application which shows how we to use NotifyIcon in the system tray and also use a menu control with it.

Screenshot - systemTray.jpg


Using the NotifyIcon component, we can put our application icon on the system tray and use a ConextMenuStrip to control the menu in the system tray.


The function of the ConextMenuStrip is the similar to that of the menu bar. It will appear only when we right click for it.

Screenshot - conextmenu.jpg

Using the code

The code for this application is very simple, you just need to know how to use it. Code for restore application, open settings, close from system tray are listed in this section:

namespace NotifyIcon
    public partial class Form1 : Form
        public Form1()
        private void Form1_Load(object sender, EventArgs e)
            Use_Notify(); // Setting up all Property of Notifyicon 

        private void Use_Notify()
            MyNotify.ContextMenuStrip = contextMenuStrip1; 
            MyNotify.BalloonTipText = "This is A Sample Application";
            MyNotify.BalloonTipTitle = "Your Application Name";

        private void Form1_Resize(object sender, System.EventArgs e)
            // Hide The Form when it's minimized
            if (FormWindowState.Minimized == WindowState)
        private void MyNotify_DoubleClick(object sender, System.EventArgs e)
            // Show the form when Dblclicked on Notifyicon
            WindowState = FormWindowState.Normal;
        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
            // Will Close Your Application 

        private void restoreToolStripMenuItem_Click(object sender, EventArgs e)
            //Will Restore Your Application 
            WindowState = FormWindowState.Normal;

        private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
            //Settings 1
            MessageBox.Show("Your Application Settings 1");

        private void settings2ToolStripMenuItem_Click(object sender, EventArgs e)
            //Settings 2
            MessageBox.Show("Your Application Settings 2");

You can apply this in any of your applications.


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


About the Author

Abhijit Jana
Technical Lead
India India
.NET Consultant | Former Microsoft MVP - ASP.NET | CodeProject MVP, Mentor, Insiders| Technology Evangelist | Author | Speaker | Geek | Blogger | Husband
Blog :
Web Site :
Twitter : @AbhijitJana
My Kinect Book : Kinect for Windows SDK Programming Guide
Follow on   Twitter

Comments and Discussions

Questionicon Pinmembersmpaliwal29-Mar-13 22:18 
GeneralMy vote of 1 PinmemberJetro2236-Dec-12 3:43 
QuestionNot bad! PinmemberBruceL5-Jul-11 4:11 
GeneralMy vote of 1 PinmemberMember 32246509-Mar-11 23:30 
GeneralMy vote of 4 Pinmemberhoerst23-Oct-10 1:15 
GeneralMy vote of 1 PinmemberJohnAndre25-Aug-10 0:09 
GeneralMy vote of 5 PinmemberMember 43370486-Aug-09 23:03 
GeneralRe: My vote of 5 PinmvpAbhijit Jana9-Aug-09 22:33 
GeneralMy vote of 1 PinmemberIngvarr24-Jul-09 2:06 
GeneralRe: My vote of 1 PinmvpAbhijit Jana26-Sep-09 23:37 
General[My vote of 1] where is the code PinmemberDonsw28-Jun-09 15:43 
GeneralMy vote of 1 Pinmemberayo1016-Jun-09 11:31 
GeneralMy vote of 1 PinmemberPri N T8-Jan-09 18:02 
GeneralWhere's the code for 'MyNotify' PinmemberMark19753-Apr-08 15:37 
GeneralRe: Where's the code for 'MyNotify' PinmvpJohn Simmons / outlaw programmer20-Apr-08 5:13 
GeneralNotify icon stays in tray... PinmemberMark James Newman11-Oct-07 13:53 
GeneralRe: Notify icon stays in tray... PinmemberAbhijit Jana15-Oct-07 20:14 
GeneralRe: Notify icon stays in tray... PinmemberMark James Newman16-Oct-07 4:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150327.1 | Last Updated 6 Oct 2007
Article Copyright 2007 by Abhijit Jana
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid