Free computer Tutorials

home
Stay at Home and Learn

Add Shorcuts to your Menu Items

 
Computer Tutorials List

 

 

 

 

 

This tutorial assumes that you have completed the first one.

In the previous tutorial, you learned how to add Sub Menus to your VB .NET forms. In this part, you'll see how to add shortcuts to your menu items

 

Underline Shortcut

To add an underline, do this:

  • Click on your New menu item once. This will select it
  • Position your cursor before the "N" of New
  • Type an ampersand symbol (&)

Type an & before the letter you want to use as a shortcut

  • Hit the return key on your keyboard
  • You should see this:

The N is now underlined

Notice that "N" of New is now underlined. If you want an underline shortcut, the ampersand character should be typed before the letter you want underlined.

Add underlines for the "F" of you File menu, the "O" of Open, the "S" of Save, and the "X" of Exit. When you're done, your menu should look like this one:

All the menu items now have shortcuts

Time to see if your shortcut works. Run your programme. To use the underline shortcuts on menus, you first hold down the Alt key on your keyboard. Then type the underline character.

  • Hold down the Alt key while your programme is running (You might not be able to see the underlines until you press the Alt key.)
  • Press the letter "F" on your keyboard
  • Then press the letter "X" (for the Exit menu)
  • Your programme should close down

All that and you didn't have to write a single line of code!

 

No more reading these lessons online - get the eBook here!

 

Key combination shortcuts

A key combination shortcut is one that appears at the end of a menu item (Ctrl + N, for example). You can easily add this option to your own programmes. So try this:

  • In Design time, select the Exit item on your menu
  • Look at the properties box on the right
  • Locate the Shortcut item:

The Shortcut Property

  • Click the black down arrow to reveal a long list of shortcuts you can use for a menu item
  • Select the CtrlX item
  • Hit the return key to accept the shortcut

A list of keyboard shortcuts

Run your programme and test out the shortcut. Don't click the File menu. Just hold down the Ctrl key on your keyboard. Then press the letter X. Again, the programme will close down.

You can add these types of shortcuts to any menu item. Just remember to choose a different key stroke combination for each one. And don't have too many of them - they'll spoil the look of your menu!

 

Now that you know how to add Menus, Sub Menus and Shortcuts it's time for you to complete your own menu bar. Click the project below to see what you need to do. It's not very difficult! In the section after the project, you'll see how to add code for your new menu bar.

 

Click here for the VB .NET Menu Project-->

<--Back to the .NET Contents Page

View all our Home Study Computer Courses