Menu Items and Event Handlers

Menu items use EventHandler delegates for associating the code that is executed in response to events raised by menu items (just like buttons). One of several constructors provided by the MenuItem class allows you to pass in an EventHandler delegate that is used to handle the Click event generated by the MenuItem. A Click event can be generated on a menu item by pressing the Enter key on the keyboard, pressing the shortcut key associated with the menu item, or clicking the menu item using the mouse.

NOTE

MenuItems that contain MenuItems do not generate a Click event. Only MenuItems that do not contain child MenuItems can generate Click events.

In the following example, the Options menu item will never generate a ...

Get Visual Basic® .NET by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.