100 likes | 275 Views
MenuStrip Object. MenuStrip Object. A menu bar is a strip across the top of a window that contains one or more menu names A menu is a group of commands, or items, presented in a list. Adding a MenuStrip. Open one of your old programs.
E N D
MenuStrip Object • A menu bar is a strip across the top of a window that contains one or more menu names • A menu is a group of commands, or items, presented in a list.
Adding a MenuStrip • Open one of your old programs. • Open the Menus and Toolbars subcategory and drag the MenuStrip object onto the form. • Change the name of the MenuStrip to mnu and then the name of your project.
Customizing a MenuStrip • Click the Type Here box on the menu bar. Type &File to identify the File menu, and then press the ENTER key • Click File in the MenuStrip object to select it, scroll in the Properties window to the (Name) property, and then change the name to mnuFileMenu • To add a menu item to the File menu, click the Type Here box below the File menu name. Type &Clear and then press ENTER to create a new menu item named Clear with C as the hot key
Customizing a MenuStrip • On the File menu, click Clear to select it, scroll in the Properties window until the (Name) property is visible, and then change the name to mnuClearItem
Event Handlers for Menu Items • In Design view, double-click the Exit menu item to open the code editing window • Code the menu item to exit the program. • In Design view, double-click the Clear menu item to open the code editing window • Code the clear item to clear all text boxes, etc.
Standard Items for a Menu • Visual Basic 2005 contains an Action Tag that allows you to create a full standard menu bar commonly provided in Windows programs • Action tags provide a way for you to specify a set of actions, called smart actions, for an object as you design a form • With a new Windows Form object open, drag the MenuStrip .NET component onto the Windows Form object. Click the Action Tag on the MenuStrip object • Click Insert Standard Items on the MenuStrip Tasks menu • Click File on the menu bar to view the individual menu items and their associated icons on the File menu