Trigger Menu Item in WinForms ContextMenuStrip (ContextMenuStripEx)

10 Jun 20211 minute to read

On selection, the context menu item functionality is handled through the Click event for further operations.

Menu items can also be operated through keyboard shortcuts. The Click event will be invoked when pressing the shortcut keys.

The below code snippet shows how to append click event for menu items through code behind.

this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
this.toolStripTextBox1.Click += new System.EventHandler(this.toolStripTextBox1_Click);
this.toolStripComboBox1.Click += new System.EventHandler(this.toolStripComboBox1_Click);
AddHandler toolStripMenuItem1.Click, AddressOf toolStripMenuItem1_Click
AddHandler toolStripTextBox1.Click, AddressOf toolStripTextBox1_Click
AddHandler toolStripComboBox1.Click, AddressOf toolStripComboBox1_Click

Trigger Menu Item