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.
Printer Friendly Download Tutorial (102KB) Download Source Code (13.3KB)
Step 1
Start Microsoft Visual Basic 2005 Express Edition, then select File then New Project... Choose Windows Application from the New Project Window, enter a name for the Project and then click OK, see below:
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:
Step 4
Draw the NotifyIcon control on Form1 and it will appear in the pane, beneath the form, see below:
Step 5
Scroll down the Windows Forms Components tab and select the ContextMenuStrip control:
Step 6
Draw the ContextMenuStrip control on the form, see below:
Step 7
Make sure the ContextMenuStrip1 control is selected in the Pane beneath the form then Click on the ContextMenuStrip at the top of Form1 and change Type Here to Exit by clicking on the text and typing in the new value, see below:
Step 8
Double click where you typed Exit on the ContextMenuStrip and enter the following in the ExitToolStripMenuItem_Click sub:
End
See Below:
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:
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:
Step 11
Save the Project as you have now finished the application, then click on Start:
When you do the following will appear in the Task Tray:
Step 12
Now right click on the icon shown in the Task Tray and a menu should appear, see below:
Step 13
Click on Exit on the menu to end the application. Try Changing the Form Icon or add other Sub Menus to the ContextMenuPanel and see what happens!