Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse a System Tray icon in VB.NET
DescriptionThis example shows how to use a System Tray icon in VB.NET.
KeywordsSystem tray, tray icon, VB.NET, NotifyIcon, ContextMenu
CategoriesVB.NET, Controls
 
In VB 6, using a system tray icon is a hassle but in VB .NET it's easy. Simply add a NotifyIcon control to the form. Use the control's Icon property to determine the icon displayed in the System Tray. Set the control's ContextMenu property to the ContextMenu control that the icon should display when the user right-clicks it. Handle the ContextMenu's events normally.

This example's mnuHappy and mnuSad context menu items change the Icon properties for the NotifyIcon and the form.

 
Private Sub mnuHappy_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles mnuHappy.Click
    Me.NotifyIcon1.Icon = m_icoHappy
    Me.Icon = m_icoHappy
End Sub

Private Sub mnuSad_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles mnuSad.Click
    Me.NotifyIcon1.Icon = m_icoSad
    Me.Icon = m_icoSad
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated