NotifyIcon::Visible Property

Gets or sets a value indicating whether the icon is visible in the notification area of the taskbar.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

property bool Visible {
	bool get ();
	void set (bool value);

Property Value

Type: System::Boolean
true if the icon is visible in the notification area; otherwise, false. The default value is false.

Since the default value is false, in order for the icon to show up in the notification area, you must set the Visible property to true.

The following code example demonstrates using the NotifyIcon class to display an icon for an application in the notification area. The example demonstrates setting the Icon, ContextMenu, Text, and Visible properties and handling the DoubleClick event. A ContextMenu with an Exit item on it is assigned to the NotifyIcon::ContextMenu property, which allows the user to close the application. When the DoubleClick event occurs, the application form is activated by calling the Form::Activate method.

#using <System.dll>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
public ref class Form1: public System::Windows::Forms::Form
   System::Windows::Forms::NotifyIcon^ notifyIcon1;
   System::Windows::Forms::ContextMenu^ contextMenu1;
   System::Windows::Forms::MenuItem^ menuItem1;
   System::ComponentModel::IContainer^ components;

      this->components = gcnew System::ComponentModel::Container;
      this->contextMenu1 = gcnew System::Windows::Forms::ContextMenu;
      this->menuItem1 = gcnew System::Windows::Forms::MenuItem;

      // Initialize contextMenu1 
      array<System::Windows::Forms::MenuItem^>^temp0 = {this->menuItem1};
      this->contextMenu1->MenuItems->AddRange( temp0 );

      // Initialize menuItem1 
      this->menuItem1->Index = 0;
      this->menuItem1->Text = "E&xit";
      this->menuItem1->Click += gcnew System::EventHandler( this, &Form1::menuItem1_Click );

      // Set up how the form should be displayed. 
      this->ClientSize = System::Drawing::Size( 292, 266 );
      this->Text = "Notify Icon Example";

      // Create the NotifyIcon. 
      this->notifyIcon1 = gcnew System::Windows::Forms::NotifyIcon( this->components );

      // The Icon property sets the icon that will appear 
      // in the systray for this application.
      notifyIcon1->Icon = gcnew System::Drawing::Icon( "appicon.ico" );

      // The ContextMenu property sets the menu that will 
      // appear when the systray icon is right clicked.
      notifyIcon1->ContextMenu = this->contextMenu1;

      // The Text property sets the text that will be displayed, 
      // in a tooltip, when the mouse hovers over the systray icon.
      notifyIcon1->Text = "Form1 (NotifyIcon example)";
      notifyIcon1->Visible = true;

      // Handle the DoubleClick event to activate the form.
      notifyIcon1->DoubleClick += gcnew System::EventHandler( this, &Form1::notifyIcon1_DoubleClick );

      if ( components != nullptr )
         delete components;

   void notifyIcon1_DoubleClick( Object^ /*Sender*/, EventArgs^ /*e*/ )

      // Show the form when the user double clicks on the notify icon. 
      // Set the WindowState to normal if the form is minimized. 
      if ( this->WindowState == FormWindowState::Minimized )
            this->WindowState = FormWindowState::Normal;

      // Activate the form. 

   void menuItem1_Click( Object^ /*Sender*/, EventArgs^ /*e*/ )

      // Close the form, which closes the application. 


int main()
   Application::Run( gcnew Form1 );

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft