wwwNotify Icon in System Tray with Context
Menu Using C#
By Abhijit Jana | 6 Oct 2007 | Unedited contribution
.NET2.0C#2.0WindowsDevIntermediate
This is a small application which will show how we can use notify icon in System Tray and
also use menu control with it.
See Also
Articles like this
Articles by this author
15
Article Browse Code Stats Revisions
2.43 (36 votes)
Sponsored Links
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
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 !
Collapse
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 underThe Code
Project Open License (CPOL)
About the Author
Abhijit Jana .NET Consultant | Former Microsoft MVP - ASP.NET | CodeProject
MVP, Mentor, Insiders| Technology Evangelist | Author | Speaker |
Geek | Blogger | Husband
Blog : http://abhijitjana.net
Twitter@AbhijitJana
Software Developer
(Senior)
India
Member
Follow on Twitter