NotifyIcon in Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This lesson describes the NotifyIcon control


This component is invisible at runtime, and can be used to display an icon in the system tray.

The system tray is the area holding the small icons in the lower-right section of the taskbar.

tray icon

You can use the NotifyIcon to indicate the application's state, and it's particularly useful for programs that have no user interface or run in the background.

You often add a context menu to the tray icon so that the user can interact with your application. For example you may include commands to minimize, restore or to close the application:

context menu

    ' set the window state to minimized
    Private Sub MinimizeToolStripMenuItem_Click(sender As Object, e As EventArgs) _
     Handles MinimizeToolStripMenuItem.Click
        Me.WindowState = FormWindowState.Minimized
    End Sub

    ' set the window state to maximized
    Private Sub MaximizeToolStripMenuItem_Click(sender As Object, e As EventArgs) _
     Handles MaximizeToolStripMenuItem.Click
        Me.WindowState = FormWindowState.Maximized
    End Sub

    ' exit the application
    Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) _
     Handles ExitToolStripMenuItem.Click
    End Sub

Previous Lesson | Next Lesson

Share This

Home | About | Contact | Privacy Policy

Copyright 2018 - All Rights Reserved.