articles

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

How to create Notify Icon in C Sharp

How to create Notify Icon in C Sharp

Anonymous User 6119 22-Jul-2010

When we want to show the icon of our application in System tray then we use notify Icon control from toolbar 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 a context menu of the notify icon. To create the menu we have to add

ContextMenuStrip control from toolbar. 

How to create Notify Icon in C Sharp

We can add the menu element by selecting ContextMenuStrip. Here I’ve added two options on the menu. To link the menu to notify icon we have to set contextMenuStrip property of notifying icon to added contextMenuStrip.

 How to create Notify Icon in C Sharp

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

How to create Notify Icon in C Sharp


c# c# 
Updated 17-Mar-2020
I am a content writter !

Leave Comment

Comments

Liked By