Export (0) Print
Expand All

NotifyIcon.Click Event

Occurs when the user clicks the icon in the notification area.

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

public event EventHandler Click

For more information about handling events, see Consuming Events.

The following code example demonstrates handling the Click event. This example assumes that you have added the code to a form containing a NotifyIcon object named NotifyIcon1.

	// Initalize the NofifyIcon object's shortcut menu. 
	private void InitializeContextMenu()
	{
		MenuItem[] menuList = new MenuItem[]{new MenuItem("Sign In"),
			new MenuItem("Get Help"), new MenuItem("Open")};
		ContextMenu clickMenu = new ContextMenu(menuList);
		NotifyIcon1.ContextMenu = clickMenu;

		// Associate the event-handling method with  
		// the NotifyIcon object's click event.
		NotifyIcon1.Click +=new System.EventHandler(NotifyIcon1_Click);
	}


	// When user clicks the left mouse button display the shortcut menu.   
	// Use the SystemInformation.PrimaryMonitorMaximizedWindowSize property 
	// to place the menu at the lower corner of the screen. 
	private void NotifyIcon1_Click(object sender, System.EventArgs e)
	{
		System.Drawing.Size windowSize = 
			SystemInformation.PrimaryMonitorMaximizedWindowSize;
		System.Drawing.Point menuPoint = 
			new System.Drawing.Point(windowSize.Width-180, 
			windowSize.Height-5);
		menuPoint = this.PointToClient(menuPoint);

		NotifyIcon1.ContextMenu.Show(this, menuPoint);
		
	}
The following sample assumes that you have added the code to a form
containing a NotifyIcon object named NotifyIcon1.

.NET Framework

Supported in: 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.

Show:
© 2014 Microsoft