|
|
Title | Use a System Tray icon in VB.NET |
Description | This example shows how to use a System Tray icon in VB.NET. |
Keywords | System tray, tray icon, VB.NET, NotifyIcon, ContextMenu |
Categories | VB.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
|
|
|
|
|
|