Home > DeveloperSection > Articles > How to create Notify Icon in C Sharp

How to create Notify Icon in C Sharp


C# C# 
Ratings:
0 Comment(s)
 3781  View(s)
Rate this:

How to create Notify Icon in C#.Net

When we want to show icon of our application in System tray then we use notify Icon control from tool bar in our application.

After adding notify Icon to our form we have to write code.

private void frmRecord_Resize(object sender, EventArgs e)

        {

//if form is minimized then it will not be displayed in taskbar.

            if (FormWindowState.Minimized == this.WindowState)

                Hide();

        }

private void notifyIcon1_DoubleClick(object sender, EventArgs e)

        {

//this will maximize the application minimized to System tray.

            Show();

            WindowState = FormWindowState.Normal;

        }

 

We can also create context menu of notify icon. To create menu we have to add ContextMenuStrip control from tool bar.

We can add menu element by selecting ContextMenuStrip. Here I’ve added two options in menu. To link menu to notifyicon we have to set contextMenuStrip property of nofifyIcon to added contextMenuStrip.

Code for contextmenustrip options.

private void restoreToolStripMenuItem_Click(object sender, EventArgs e)

        {

            Show();

            WindowState = FormWindowState.Normal;

        }

 

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)

        {

            Application.Exit();

        }

Screen shot


Don't want to miss updates? Please click the below button!

Follow MindStick