Adding Menus to a Visual Basic .NET Form

In this section we’ll see how to add menus to a Visual Basic .NET form. These type of menus are very common to Windows programme. Visual Basic itself has many of these drop down menus - File, Edit, View, Project, Format, etc. And they’re very easy to add.


Start a new project. To your new form, use the toolbox to add a MenuStrip control:

The MenuStrip Item on the Toolbox

Double click the control to add one to your form. When you do, you'll notice two things. At the top of your form, you'll see this:

A menu has been added to the form

We'll see how to construct our menu soon. But notice the other things that gets added to your project. Examine the bottom of your screen, on the left. You'll see this:

The Menu Object

This is the control itself. If you click on this (it's highlighted above), you'll see that the Properties box on the right changes. There are many properties for the control. But there are lots of properties for the MenuItem object. The MenuItem object is the one at the top of the form - The one that says Type Here.

To start building your menu, click inside the area that says "Type Here". Type the word File:

Type a File Item

Now press the enter key on your keyboard. Your menu will look like this:

The Item has been added to the menu

To create items on your File menu, click inside the Type Here box. Enter the word New, and press the enter key on your keyboard again. Your menu will then look like this:

Add a New Menu Item in VB NET

Add an "Open" and a "Save" item to your menu in the same way. It should look like this:

Open and Save Items have been added to the Menu

The final item we'll add to our menu is an "Exit" item. But you can add a separator between the "Save" and "Exit".

To add a separator, click inside the "Type Here" box. Instead of typing a letter, type the minus character "-" (in between the "0" key and the "+/=" key on your keyboard). When you hit your return key, you'll see the separator appear:

Add a menu Separator

Click inside the "Type Here" area, and add an Exit (or Quit) item. Click back on your form, away from the menu, to finish off. You should now have a File menu like this one:

The finished VB File menu

To see what your menu look like, Run your programme. Click the File menu. We haven't added any code to the menu yet, so nothing will happen if you click an item on the menu. But it does look quite good. Very professional!


In the next part, we'll see how to add some code to the Quit menu.