110 likes | 320 Views
Creating Menu. Objectives. Create a menu system for a form Create a menu Create a menu titles Create a menu items Create a submenu Modify menu Edit menu Create event handlers for menus. Creating Menus.
E N D
Objectives • Create a menu system for a form • Create a menu • Create a menu titles • Create a menu items • Create a submenu • Modify menu • Edit menu • Create event handlers for menus
Creating Menus • Create menus for a program to give the user an alternative to clicking buttons on a form • Menus reduce the clutter on a form • VB .NET menus work the same way as menus in any other application • Menu bar appears just below a form's title bar • Create menus using the MainMenu control • Control is invisible so it appears in the resizable tray below the from
The MenuItem Class (Properties) • Checked property defines a checked menu item • Check mark appears to the left of the menu item • Enabled property controls whether menu items will respond to events • Disabled menu items appear grayed • Name property has the same meaning as with other controls • ShowShortcut property controls whether a shortcut key will appear if one is defined • Text property controls text appearing in the menu item • Visible property controls whether menu item or menu title is visible • If menu is not visible, sub menus of that menu are not visible
Creating a Menu • Create an instance of the MainMenu control on the form • Use the standard prefix of "mmu" • Create the menu items "in place" in the Win Form Designer • Use descriptive names with the 1st character of each word capitalized • Edit the Name properties as necessary • Create Click event handlers for each menu item
Creating a Menu Click here to edit menu "in place" MainMenu control instance
Creating Menu titles Menu titles appear below title bar
Creating Menu Items Menu items appear below menu titles
Creating a Sub Menu Arrows indicate a sub menu Sub menu
Modifying a Menu • Right-click on the menu you want to modify • Select one of the following from the context menu • Delete to remove the menu title or menu item • Insert New to insert a new menu • InsertSeparator to insert a separator bar • EditNames to edit the Name property for the menus "in place" • ViewCode to activate the Code Editor for the selected menu item • VB .NET will create the Click event handler • Properties to activate the Properties window
Editing Menu Names Menu name appears in brackets