Click here to Skip to main content
6,295,667 members and growing! (15,093 online)
Email Password   helpLost your password?
Languages » C# » General     Intermediate License: The Code Project Open License (CPOL)

Notify Icon in System Tray with Context Menu Using C#

By Abhijit Jana

This is a small application which will show how we can use notify icon in System Tray and also use menu control with it.
C# 2.0, Windows, .NET 2.0, Dev
Posted:5 Oct 2007
Views:25,327
Bookmarked:26 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
28 votes for this article.
Popularity: 3.14 Rating: 2.17 out of 5
15 votes, 53.6%
1

2
3 votes, 10.7%
3
1 vote, 3.6%
4
9 votes, 32.1%
5
Screenshot - systemTray.jpg

Introduction

Using NotifyIcon Components we can put our application icon on Sysytem Tray and ConextMenuStrip will use to control the menu in System Tray

Background

Function of ConextMenuStrip is same as menu bar. It will appear only when we Right Click

Screenshot - conextmenu.jpg

Using the Code

code of this application is very simple, just need to know how to use !

some code like, Restore Application, Open Settings, Close from System Tray are given in this Section !

namespace NotifyIcon
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
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";
MyNotify.ShowBalloonTip(1); 
}

private void Form1_Resize(object sender, System.EventArgs e)
{
// Hide The Form when it's minimized

if (FormWindowState.Minimized == WindowState)
Hide();
}
private void MyNotify_DoubleClick(object sender, System.EventArgs e)
{
// Show the form when Dblclicked on Notifyicon

Show();
WindowState = FormWindowState.Normal;
}
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
// Will Close Your Application 

MyNotify.Dispose();
Application.Exit();
}

private void restoreToolStripMenuItem_Click(object sender, EventArgs e)
{
//Will Restore Your Application 

Show();
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");
}
} 

Points of Interest

You can Apply it with any of your Application !

License

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

About the Author

Abhijit Jana


Member
Abhijit has done Master Degree in Computer Application from Heritage Institute of Technology (HIT-K) ,Kolkata, West Bengal, India . He is an interested, committed, creative Software professional having more than 2 years of solid experience in web-based and windows based solutions in Microsoft Technologies using ASP.NET 2.0, C# 2.0, AJAX, Web Services, MS SQL Server 2005, Exchange Server, Active Directory, and Dot Net Nuke (DNN),Win Forms, WinServices, WSS (Windows Sharepoint Server 3.0 ). He is also an MCP (Microsoft Certified Professional) and MCTS (Microsoft Certified Technology Specialist) on Web Development. He has good knowledge of Object Oriented Programming, 3-Tier Architecture and Designing as well as good command over IIS (IIS 5.1,IIS 6.0, IIS 7.0) and deployment of Application on Live Production Environment . His hobbies, listing to music and Developing Own small Tools Utilities and Knowledge sharing.
Awards

CodeProject MVP 2009
Prize winner "Best ASP.NET article of January 2009"
Prize winner "Best ASP.NET article of November 2008"

Prize winner "Best ASP.NET article of October 2008"

Abhijit's CodeProject Guru :
Sacha Barber
Abhijit's Articles
View My CodeProject Articles


Mail Me @: mca_abhijit@yahoo.co.in

My Blog : http://abhijitjana.net
Occupation: Software Developer
Location: India India

Other popular C# articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 9 of 9 (Total in Forum: 9) (Refresh)FirstPrevNext
GeneralMy vote of 1 PinmemberJohannes Hillert5:22 4 Jul '09  
General[My vote of 1] where is the code PinmemberDonsw15:43 28 Jun '09  
GeneralMy vote of 1 Pinmemberayo1011:31 16 Jun '09  
GeneralMy vote of 1 PinmemberPri N T18:02 8 Jan '09  
GeneralWhere's the code for 'MyNotify' PinmemberMark197515:37 3 Apr '08  
GeneralRe: Where's the code for 'MyNotify' PinmvpJohn Simmons / outlaw programmer5:13 20 Apr '08  
GeneralNotify icon stays in tray... PinmemberMark James Newman13:53 11 Oct '07  
GeneralRe: Notify icon stays in tray... PinmemberAbhijit Jana20:14 15 Oct '07  
GeneralRe: Notify icon stays in tray... PinmemberMark James Newman4:31 16 Oct '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 5 Oct 2007
Editor:
Copyright 2007 by Abhijit Jana
Everything else Copyright © CodeProject, 1999-2009
Web17 | Advertise on the Code Project