Menus and Menu Items

There are three main classes that you will use to create menus in Microsoft .NET. These classes are MainMenu, MenuItem, and ContextMenu. These classes are part of the System.Windows.Forms assembly of the Microsoft .NET Framework.

Let's walk through an example of adding a menu to a form using the Form Designer window. This is the most common way to add a menu to a form, as this is the easiest way to do this. You start by dragging a MainMenu control from the toolbox onto the form. Once you drop it on the form, a menu appears, and a MainMenu1 control appears at the bottom of the Form Designer window. This is shown in Figure 24.3.

Figure 24.3. Adding a menu to a form.

To define the menu structure, you simply type in the visible ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.