|
Free
computer Tutorials
|
![]() |
home |
Stay
at Home and Learn
|
||||||
Adding Menus to a Visual Basic .NET Form |
|||||||
|
In this section well 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 theyre very easy to add.
Start a new project. To your new form, use the toolbox to add a Main Menu control:
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:
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:
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 on the MenuItem object. It will change to this:
The "Type Here" box moves down one place. You get a second "Type Here" area to the right of the first one. This is for the second drop-down menu. Type the word File in the textbox at the top, and the press the return key on your keyboard. You'll see this:
Click inside the blue "Type Here" area, and the menu changes to this:
Type the word New , and then hit your return key. You should then have this:
Add an Open and a Save item to your menu in the same way. It should look like this:
The final item we'll add to our menu is an "Exit" item. But you can add a separator between the "Save" and "Exit".
No more reading these lessons online - get the eBook here!
To add a separator, click inside the blue "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:
Click inside the blue "Type Here" area, and add an Exit item. Click back on your form, away from the menu, to finish off. You should now have a File menu like this one:
To see what your menu look like, Run your programme. Click the File menu and you should have one that looks like this:
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 Exit menu.
Click here to learn how to add code to your VB .NET Menus --> <--Back to the .NET Contents Page |