Nested Menus

Menus can, of course, be nested. A menu can have a submenu and items. The submenu can also have a submenu, items, and so on. Nested menus are quite simple to create in VB .NET using the Framework classes. Each MenuItem object can contain a list of child MenuItem objects. This list is represented by the MenuItems property on the MenuItem class. MenuItems is a collection of MenuItem objects.

If the MenuItems property contains zero MenuItems this means the MenuItem does not have a submenu and is considered to be a leaf menu. If you think of a tree as an analogy, a tree has branches and each branch extends outward to form more branches. Each branch ends with a leaf. A leaf MenuItem is considered the last MenuItem extending from the main ...

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.