MainMenu

Represents the menu structure of a form.

The MainMenu control represents the container for the menu structure of a form. A menu is composed of MenuItem objects that represent the individual menu commands in the menu structure. Each MenuItem can be a command for your application or a parent menu for other submenu items. To bind the MainMenu to the Form that will display it, assign the MainMenu to the Menu property of the Form.

For applications that will have support for multiple languages, you can use the RightToLeft property to display the text of the menu from right to left to support languages such as Arabic.

You can create different MainMenu objects to represent different menu structures for your form. If you want to reuse the menu structure contained in a specific MainMenu, you can use its CloneMenu method to create a copy. Once you have a copy of the menu structure, you can make the appropriate modifications for your new menu structure.

For a full list of properties, methods and events see the API documentation.

Features

Auto Overflow

When set, the AutoOverflow property will automatically show an overflow icon when there are too many items to display in the menu.

LinkMenuItems provide a simple way to create menu items that open a specified URL.

Shortcuts

Shortcut keys provide a method for users to activate frequently used menu items in your menu system and to provide keyboard access to your application for those users who do not have access to a mouse or other pointer device.

How To

Add Items

Menu Items can be added to a Form in the designer by dragging the MainMenu component from the Toolbox onto the Form. The MenuItems property can be expanded to add new members.

To programmatically add menu items to a form, see the example below.

public void CreateMenu()
{
   // Create an empty MainMenu.
   MainMenu mainMenu1 = new MainMenu();

   MenuItem menuItem1 = new MenuItem();
   MenuItem menuItem2 = new MenuItem();

   menuItem1.Text = "File";
   menuItem2.Text = "Edit";
   // Add two MenuItem objects to the MainMenu.
   mainMenu1.MenuItems.Add(menuItem1);
   mainMenu1.MenuItems.Add(menuItem2);
   
   // Bind the MainMenu to Form1.
   this.Menu = mainMenu1;   
}

Advanced

JavaScript Widget

ItemDescription

Class name

"wisej.web.menu.MainMenu"

Theme appearance

"mainmenu", inherits from "menubar", see Themes.

Source code

Last updated