To create menus, follow the steps:
1. Press Alt + T to open the 'Tools Menu' and then select the "Menu Editor" from the list of options. A "Menu Editor" window will appear. You can also press 'Ctrl + E' to directly open the Menu Editor window in Visual Basic.
2. The 'Menu Editor" window has the following options and boxes:
Caption: Start creating a new menu by entering the caption of the item you want in your menu. The caption property sets the name that you want to display on the Menu Bar. Use the ampersand (&) symbol to specify the shortcut for a particular item. For example, if you write &File in the caption then the shortcut symbol for File option will be 'Alt + F'. The ampersand (&) symbol specifies that the following keyword will be used as a shortcut key to access from the keyboard.
Name: Name is required and can't be left blank. It specifies the name for the menu button that will be used while coding the behavior of the menu bar. Naming standard for a menu name is "mnu" followed by the name you specify. Therefore, the name for the File menu is "mnuFile" i.e. use "mnu" as prefix and then the actual menu name.
Shortcut: Now after setting the caption and name properties, if you want to assign a shortcut key that should appear along with the menu item, then it can be assigned by specifying the one in the shortcut menu option.
To add more items to your menu, click the "next" button or press enter. The text box will clear and the name of your first menu item will appear in the menu list box below the Menu Editor window.
To add a submenu to any menu item, click the right arrow button that will move the pointer to the right and then you can repeat the above steps to add a submenu to an existing menu item.
To continue adding more items to the menu without creating any submenu, just press 'Next' and the new menu item will appear. You can use the arrow keys to move the pointer to the desired location that will allow you to edit previously added menu items or if you need to change any other menu item.
Coding for menu command:
Your menu doesn't start working immediately unless and until you define a procedure for the same. IN other words, you need to write the code for your menu item in order to perform the desired function. For example, for "EXIT" menu we have to write the following line of code;
mnuEXIT_click()
Now code the procedure for the exit by pulling down the menu and clicking on the word exit
Other options:
A menu command may contain a check mark beside it (checked), or it may be grayed (disable). An enabled menu item appears in black text and is available for selection, whereas, a grayed out or disabled item is not available to the user for some reason. Eventually, a check mark can be placed next to the menu item to indicate that the option is currently selected.
Check marks are often used for menu commands that can be toggled on and off e.g. for the bold option, the check mark would indicate that bold option is currently selected. Choosing the bold command for the second time should remove the check mark and turn off the bold option.
By default, menu commands are enabled. If you wish the item to be grayed out, the check box must be empty.
If you create a menu option that can be turned on and off, you should include a check mark to indicate the current state. You can set the initial state of the check mark in the menu editor. In the code you can change it's setting by setting the menu item's checked property.
If mnuformatbold.checked=True Then
mnuFormatBold.checked=False
txtChangeable.Font.Bold=True
Else
mnuFormatBold.checked=True
txtChangeable.Font.bold=True
Published by Harsh Gupta - Tech Writer
I am a part time freelancer and writing is my hobby Some of my websites: http://www.GenericArticles.com http://www.JailBreakingiPhone.com View profile
- Building a Basic CSS Menu
- How to Create a Navigation Menu for Dummies
- Wedding Menu Ideas and Inspirations
- The Ultimate Guide to Menu Planning
- Easy Way to Create Out-of-Office Response for Microsoft Outlook 2003
- Check Off: Another To-Do List Manager for Mac
- The Best Tutorial Sites for Visual Basic.NET
|
|
- By default, menu commands are enabled.
- If you wish the item to be grayed out, the check box must be empty
1 Comments
Post a Commentit helps me a lot