Task Tray

This will show you how to put an Icon in the Task Tray and make a Menu appear when you right click on the Icon in the Task Tray.


Step 1

Load Microsoft Visual Studio.NET then select Visual Basic Projects, Windows Application, enter a name for the Project and then click OK, see below:

New Project

Step 2

A Blank Form named Form1 should then appear, see below:


Step 3

Scroll down the Windows Forms Components tab and select the NotifyIcon control:

NotifyIcon Control

Step 4

Draw the NotifyIcon control on Form1 and it will appear in the pane, beneath the form, see below:

NotifyIcon Control in Pane

Step 5

Scroll down the Windows Forms Components tab and select the ContextMenu control:

ContextMenu Control

Step 6

Draw the ContextMenu control on the form, see below:

Form with ContextMenu

Step 7

Make sure the ContextMenu1 control is selected in the Pane beneath the form then Click on the ContextMenu at the top of Form1 and change Type Here to Exit by clicking on the text and typing in the new value, see below:

Form with ContextMenu with Exit

Step 8

Double click where you entered Exit on the ContextMenu and enter in the MenuItem1_Click sub:


See Below:

ContextMenu MenuItem Click Event

Step 9

Click on the NotifyIcon1 control in the Pane beneath Form1, then go to the Properties box and set the ContextMenu property to ContextMenu1, see below:

NotifyIcon Properties

Step 10

Double Click on Form1 and type in the Form1_Load Sub:

NotifyIcon1.Icon = Me.Icon
NotifyIcon1.Visible = True
NotifyIcon1.Text = "Task Tray"

See Below:

Form1 Load Event

Step 11

Save the Project as you have now finished the application, select Release and Click on Start:

Start (Release)

When you do the following will appear:

Application Running

Step 12

Now right click on the icon shown in the Task Tray and a menu should appear, see below:

Task Tray with Menu

Step 13

Click on Exit on the menu to end the application. Try Changing the Form Icon or add other Sub Menus to the ContextMenu and see what happens!