Handling Menu Events

When the basic menu structures are in place, it is time to write the code that reacts to a user selecting one of those menu items. This involves crafting event handles for the menu items previously declared and writing code to react to those events.

Menu Items and Event Handlers

There are two different ways to link menu items to a piece of code that will run when the menu item is selected. The first way is to use the click event that the MenuItem class exposes. The click event is fired whenever a menu item is selected. Note that although the event is called click, it is fired regardless of how the item is selected. For instance, a user navigating to a menu item by using the keyboard and then pressing the Enter key causes ...

Get Visual Basic® Programmer's Guide to the .NET Framework Class Library 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.