New to Telerik UI for WinFormsStart a free 30-day trial

ContextMenu

Updated over 6 months ago

You can display a context menu when the user interacts with the notify icon with the help of the TrayContextMenu property.

TrayContextMenu

The TrayContextMenu property expects a value of type RadContextMenu. Example 1 demonstrates how it can be used.

C#

void SetContextMenu()
{
	RadNotifyIcon radNotifyIcon = new RadNotifyIcon();
	radNotifyIcon.TrayIcon = new System.Drawing.Icon("../../WinForms128x28.ico");
	radNotifyIcon.ContextMenuActivationMouseEvent = MouseActivationEvent.RightClick;
	radNotifyIcon.ShowTrayIcon = true;
	radNotifyIcon.PopupContent = new UserControl1();          
	var contextMenu = new RadContextMenu();
	contextMenu.Items.Add(new RadMenuItem("Item 1"));
	contextMenu.Items.Add(new RadMenuItem("Item 2"));
	contextMenu.Items.Add(new RadMenuItem("Item 3"));
	radNotifyIcon.TrayContextMenu = contextMenu;
}

Figure 1: RadContextMenu displayed over the icon

RadContextMenu displayed over the icon

ContextMenuActivationMouseEvent

The ContextMenuActivationMouseEvent property determines when the context menu will be shown. The default value is RightClick. This property is enumeration and it expose the following values:

  • LeftClick: Triggered on left mouse click.
  • RightClick: Triggered on right mouse click.
  • MiddleClick: Triggered on middle mouse click.
  • LeftDoubleClick: Triggered on left mouse double click.
  • RightDoubleClick: Triggered on right mouse double click.
  • MiddleDoubleClick: Triggered on middle mouse double click.
  • All: Triggered on any mouse click action.
C#

radNotifyIcon.ContextMenuActivationMouseEvent = MouseActivationEvent.MiddleClick;