Create system tray icon in windows forms application using C# and VB.Net

Tutorials PanelPosted by

Below is an example of how to create system tray icon in a Windows Application (WinForms) using c# and vb.NET.

Here are the steps to follow in order to complete this tutorial.

Step 1

Create a windows form application

create-winforms-app

Step 2

Add a NotifyIcon to the main form

NotifyIcon

Step 3

Add an icon to the NotifyIcon

Note: it’s very important to add an icon to the NotifyIcon. Otherwise the NotifyIcon will not show up.

Add-icon

Step 4

Add the code below to the Form Load event

C#

        private void frm_Load(object sender, EventArgs e)
        {
       
            notifyIcon1.BalloonTipIcon = ToolTipIcon.Info;

            notifyIcon1.BalloonTipText = "Welcome to TutorialsPanel.com!!";

            notifyIcon1.BalloonTipTitle = "Welcome Message";

            notifyIcon1.ShowBalloonTip(2000);
        }

VB.NET

Private Sub frm_Load(sender As Object, e As EventArgs)

	notifyIcon1.BalloonTipIcon = ToolTipIcon.Info

	notifyIcon1.BalloonTipText = "Welcome to TutorialsPanel.com!!"

	notifyIcon1.BalloonTipTitle = "Welcome Message"

	notifyIcon1.ShowBalloonTip(2000)
End Sub

Step 5

Run the application

notify-icon

Step 6

Now let add a Double Click event on the NotifyIcon. Double click on the NotifyIcon in the design view, and then add the code below to the event

C#

        private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            MessageBox.Show("Someone just double clicked on the icon!");
         
            notifyIcon1.Visible = false;
        }

VB.NET

Private Sub notifyIcon1_MouseDoubleClick(sender As Object, e As MouseEventArgs)
	MessageBox.Show("Someone just double clicked on the icon!")
        notifyIcon1.Visible = False
End Sub

Step 7

Double Click on the icon in the system tray

notifyicon-double-click

Related Article:

Get Computer Name Using VB.NET

Get computer name using C#

 

3 comments

Leave a Reply