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

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

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