Dynamic Menus

All of the menu examples shown so far assume that you know the exact menu structure at the time you develop your application. Sometimes this menu is not known until after the application is built. A list of possible menu items may be defined in a configuration file or come from a database (the support for this is up to you to develop).

In any event, MenuItems allow you to define sub MenuItems while the application is running. This is accomplished through the use of events. When you move the cursor over a MenuItem, a Select event is dispatched to the MenuItem. This event can be intercepted to perform a number of different tasks such as constructing a submenu dynamically.

Using the nested menu example based on a deck of cards again, ...

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.