Windows Forms: How to create a System tray Notification in C#

How to create a system tray in c# .net using NotifyIcon control, and how to write the code so that when you minimize your application, it hides itself and shows a balloon tip, with custom text as the title of the balloon tip and custom text as the balloon tip description

Step 1Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "SystemTray" and then click OK

systemtray c#Step 2: Design your form as below

c# system tray

Add a ContextMenuStrip, NotifyIcon to your windows form application

c# notifyicon

Step 3: Add code to handle your windows forms as below

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SystemTray
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void showToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Show();
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Exit your program
            Application.Exit();
        }

        private void Form1_Move(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                this.Hide();
                //Show ballon tip
                notifyIcon1.ShowBalloonTip(1000, "Important notice", "Something important has come up. Click this to know more.", ToolTipIcon.Info);
            }
        }

        private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            this.Show();
        }
    }
}

VIDEO TUTORIALS