# MainMenu

The Wisej.NET `MainMenu` control contains a form's menu structure. It consists of `MenuItem` objects representing individual menu commands or submenus. Bind the `MainMenu` to a form by assigning it to the form's `Menu` property.

For multilingual support, use the `RightToLeft` property to display menu text appropriately for languages like Arabic.

Create different `MainMenu` objects for varied menu structures. Use `CloneMenu` to create reusable copies that can be modified for new menu structures.

{% hint style="info" %}
For a full list of properties, methods and events see the [API documentation.](http://docs.wisej.com/api)
{% endhint %}

## Features

### Auto Overflow

The `AutoOverflow` property automatically displays an overflow icon when menu items exceed available space.

![MainMenu showing overflow icon](/files/-Me5y160IpNeSz0K6iiu)

### Link Menu Items

`LinkMenuItem` objects provide URL-opening menu items.

![MainMenu with link menu items](/files/-MjQ8C-XFUDD8zp-f9lT)

### Shortcuts

Shortcut keys enable quick access to frequent menu items and keyboard navigation for users without pointer devices.

![MainMenu items with shortcut keys](/files/-MjQA42IjJEtUrHvaOH5)

## How To

### Add Items

Add menu items in the designer by:

1. Drag `MainMenu` from Toolbox to Form
2. Expand `MenuItems` property to add members

For programmatic menu item addition:

{% tabs %}
{% tab title="C#" %}

```csharp
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;   
}
```

{% endtab %}
{% endtabs %}

## Advanced

### JavaScript Widget

| Item             | Description                                                                                                         |
| ---------------- | ------------------------------------------------------------------------------------------------------------------- |
| Class name       | "wisej.web.menu.MainMenu"                                                                                           |
| Theme appearance | "mainmenu", inherits from "menubar", see [Themes](https://docs.wisej.com/theme-builder/theme-elements/elements)     |
| Source code      | [https://github.com/iceteagroup/wisej-js](https://github.com/iceteagroup/wisej-js/blob/master/wisej.web.TextBox.js) |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/docs/controls/menus/mainmenu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
