O'Reilly logo

Visual Basic® .NET by Example by Bob Donald, Gabriel Oancea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required