Training
Module
Work with files and directories in a .NET app - Training
Learn how to use .NET, C#, and System.IO to work with directories, paths, files, and the file system.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The Windows Forms NotifyIcon component displays a single icon in the status notification area of the taskbar. To display multiple icons in the status area, you must have multiple NotifyIcon components on your form. To set the icon displayed for a control, use the Icon property. You can also write code in the DoubleClick event handler so that something happens when the user double-clicks the icon. For example, you could make a dialog box appear for the user to configure the background process represented by the icon.
Note
The NotifyIcon component is used for notification purposes only, to alert users that an action or event has occurred or there has been a change in status of some sort. You should use menus, toolbars, and other user-interface elements for standard interaction with applications.
Assign a value to the Icon property. The value must be of type System.Drawing.Icon
and can be loaded from an .ico file. You can specify the icon file in code or by clicking the ellipsis button () next to the Icon property in the Properties window, and then selecting the file in the Open dialog box that appears.
Set the Visible property to true
.
Set the Text property to an appropriate ToolTip string.
In the following code example, the path set for the location of the icon is the My Documents folder. This location is used because you can assume that most computers running the Windows operating system will include this folder. Choosing this location also enables users with minimal system access levels to safely run the application. The following example requires a form with a NotifyIcon control already added. It also requires an icon file named Icon.ico
.
' You should replace the bold icon in the sample below
' with an icon of your own choosing.
NotifyIcon1.Icon = New _
System.Drawing.Icon(System.Environment.GetFolderPath _
(System.Environment.SpecialFolder.Personal) _
& "\Icon.ico")
NotifyIcon1.Visible = True
NotifyIcon1.Text = "Antivirus program"
// You should replace the bold icon in the sample below
// with an icon of your own choosing.
// Note the escape character used (@) when specifying the path.
notifyIcon1.Icon =
new System.Drawing.Icon (System.Environment.GetFolderPath
(System.Environment.SpecialFolder.Personal)
+ @"\Icon.ico");
notifyIcon1.Visible = true;
notifyIcon1.Text = "Antivirus program";
// You should replace the bold icon in the sample below
// with an icon of your own choosing.
notifyIcon1->Icon = gcnew
System::Drawing::Icon(String::Concat
(System::Environment::GetFolderPath
(System::Environment::SpecialFolder::Personal),
"\\Icon.ico"));
notifyIcon1->Visible = true;
notifyIcon1->Text = "Antivirus program";
.NET Desktop feedback feedback
.NET Desktop feedback is an open source project. Select a link to provide feedback:
Training
Module
Work with files and directories in a .NET app - Training
Learn how to use .NET, C#, and System.IO to work with directories, paths, files, and the file system.
Documentation
NotifyIcon Component Overview - Windows Forms .NET Framework
This article presents an overview of the NotifyIcon component in Windows Forms, which is used to display icons for processes that run in the background.
Associate a Shortcut Menu with NotifyIcon Component - Windows Forms .NET Framework
Learn how to associate a shortcut menu with a Windows Forms NotifyIcon component to add functionality to applications.
NotifyIcon Component - Windows Forms .NET Framework
Learn about the NotifyIcon component in Windows Forms, which displays icons in the the taskbar for processes that run in the background.
Set an app icon (Visual Basic, C#) - Visual Studio (Windows)
Learn how to specify the icon that File Explorer and the Windows taskbar display for a compiled Visual Basic or C# application.