How to place C#.Net windows application to System Tray?

This C#.net tutorial explains, how we can place a windows application to System Tray using C#.Net.

Place C#.Net windows application to System Tray

In this example we will see when the user minimizes the form then the form will reside in the System Tray.

Follow the below steps to place C#.Net windows application to System Tray.

Create a form (Right click on the Project, then Click on Add -> Add Windows Form…)

Then drag and drop an NotifyIcon from the Toolbox. And then Right click on the NotifyIcon and click on Properties. There you can give a proper name, also you can upload an icon (.ico) file and then you can set the Text property which will appear when the user put the cursor on the NotifyIcon. It should be look like below:

Now generate the event handler for the Resize evernt of the form and write the below code:

Here If the user click on Minimize it will hide the form.

private void Form1_Resize(object sender, EventArgs e)
    {
        if (FormWindowState.Minimized == WindowState)
        {
            Hide();
        }
    }

Now generate an event handler for the DoubleClick event of the NotifyIcon and write the below code.

Here when user doubleclick on the NotifyIcon then it will show the form.

private void notifyIcon1_DoubleClick(object sender, EventArgs e)
 {
 Show();
 WindowState = FormWindowState.Normal;
 }

Now run the application and click on minimize, then the form will place in the System tray.

You may like following C#.Net tutorials:

Hope this C#.net tutorial explains, how to place C#.Net windows application to System Tray?

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

>