# MainMenu

Namespace: **Wisej.Web**

Assembly: **Wisej.Framework** (4.0.0.0)

* [Component](/api/wisej.base/general/wisej.base.component.md)
  * [Component](/api/wisej.web/general/wisej.web.component.md)
    * [BindableComponent](/api/wisej.web/general/wisej.web.bindablecomponent.md)
      * [Menu](/api/wisej.web/menus/wisej.web.menu.md)
        * [MainMenu](/api/wisej.web/menus/wisej.web.mainmenu.md)

Represents the main menu in a [Form](#form).

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

```csharp
public class MainMenu : Menu
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class MainMenu
    Inherits Menu
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](/files/hsR4ok3152WyAf8J2C1u) MainMenu()

Initializes a new instance of the [MainMenu](/api/wisej.web/menus/wisej.web.mainmenu.md) class without any specified menu items.

### ![](/files/hsR4ok3152WyAf8J2C1u) MainMenu(container)

Initializes a new instance of the [MainMenu](/api/wisej.web/menus/wisej.web.mainmenu.md) class with the specified container.

| Name          | Type                                                                                 | Description                                                                                                                                                                       |
| ------------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **container** | [IContainer](https://docs.microsoft.com/dotnet/api/system.componentmodel.icontainer) | An [IContainer](https://docs.microsoft.com/dotnet/api/system.componentmodel.icontainer) representing the container of the [MainMenu](/api/wisej.web/menus/wisej.web.mainmenu.md). |

### ![](/files/hsR4ok3152WyAf8J2C1u) MainMenu(items)

Initializes a new instance of the [MainMenu](/api/wisej.web/menus/wisej.web.mainmenu.md) with a specified set of [MenuItem](/api/wisej.web/menus/wisej.web.menuitem.md) objects.

| Name      | Type                                                       | Description                                                                                                                                                  |
| --------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **items** | [MenuItem\[\]](/api/wisej.web/menus/wisej.web.menuitem.md) | An array of [MenuItem](/api/wisej.web/menus/wisej.web.menuitem.md) objects that will be added to the [MainMenu](/api/wisej.web/menus/wisej.web.mainmenu.md). |

## Properties

### ![](/files/hsR4ok3152WyAf8J2C1u) AutoOverflow

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Enables the overflow handling which automatically removes items that don't fit in the [MainMenu](/api/wisej.web/menus/wisej.web.mainmenu.md) and adds them to a drop-down button. (Default: `True`)

### ![](/files/hsR4ok3152WyAf8J2C1u) BackColor

[Color](https://docs.microsoft.com/dotnet/api/system.drawing.color): Returns or sets the background color of the main menu bar.

### ![](/files/hsR4ok3152WyAf8J2C1u) CausesValidation

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets whether clicking menu items causes validation to be performed on the active control. (Default: `False`)

### ![](/files/hsR4ok3152WyAf8J2C1u) Enabled

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets whether the menu is visible. (Default: `True`)

### ![](/files/hsR4ok3152WyAf8J2C1u) Font

[Font](https://docs.microsoft.com/dotnet/api/system.drawing.font): Returns or sets the font of the main menu bar.

### ![](/files/hsR4ok3152WyAf8J2C1u) ForeColor

[Color](https://docs.microsoft.com/dotnet/api/system.drawing.color): Returns or sets the text color of the main menu bar.

### ![](/files/hsR4ok3152WyAf8J2C1u) RightToLeft

[RightToLeft](/api/wisej.web/enumerations/wisej.web.righttoleft.md): Returns or sets whether the text displayed by the control is displayed from right to left.

### ![](/files/hsR4ok3152WyAf8J2C1u) Visible

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets whether the menu is visible. (Default: `True`)

## Methods

### ![](/files/hsR4ok3152WyAf8J2C1u) CloneMenu()

Creates a new [MainMenu](/api/wisej.web/menus/wisej.web.mainmenu.md) that is a duplicate of the current [MainMenu](/api/wisej.web/menus/wisej.web.mainmenu.md).

**Returns:** [MainMenu](/api/wisej.web/menus/wisej.web.mainmenu.md). A [MainMenu](/api/wisej.web/menus/wisej.web.mainmenu.md) that represents the cloned menu.

### ![](/files/lzopMboA31bVq8UIcbT3) Dispose(disposing)

Disposes of the resources, other than memory, used by the [MainMenu](/api/wisej.web/menus/wisej.web.mainmenu.md).

| Parameter     | Type                                                            | Description                                                                 |
| ------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------- |
| **disposing** | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) | true when this method is called by the application rather than a finalizer. |

### ![](/files/hsR4ok3152WyAf8J2C1u) GetForm()

Returns the [Form](/api/wisej.web/containers/form.md) that contains this menu.

**Returns:** [Form](/api/wisej.web/containers/form.md). A [Form](/api/wisej.web/containers/form.md) that is the container for this menu. Returns null if the [MainMenu](/api/wisej.web/menus/wisej.web.mainmenu.md) is not currently hosted on a form.

### ![](/files/hsR4ok3152WyAf8J2C1u) Hide()

Hides the main menu.

### ![](/files/lzopMboA31bVq8UIcbT3) OnBackColorChanged(e)

Fires the [BackColorChanged](#backcolorchanged) event.

| Parameter | Type                                                                | Description                                                                                         |
| --------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| **e**     | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | A [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnEnabledChanged(e)

Fires the [EnabledChanged](#enabledchanged) event.

| Parameter | Type                                                                | Description                                                                                          |
| --------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| **e**     | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | An [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnFontChanged(e)

Fires the [FontChanged](#fontchanged) event.

| Parameter | Type                                                                | Description                                                                                         |
| --------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| **e**     | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | A [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnForeColorChanged(e)

Fires the [ForeColorChanged](#forecolorchanged) event.

| Parameter | Type                                                                | Description                                                                                         |
| --------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| **e**     | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | A [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnMenuItemAdded(e)

| Parameter | Type                                                                     | Description |
| --------- | ------------------------------------------------------------------------ | ----------- |
| **e**     | [MenuItemEventArgs](/api/wisej.web/menus/wisej.web.menuitemeventargs.md) |             |

### ![](/files/lzopMboA31bVq8UIcbT3) OnVisibleChanged(e)

Fires the [VisibleChanged](#visiblechanged) event.

| Parameter | Type                                                                | Description                                                                                         |
| --------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| **e**     | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | A [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnWebRender(config)

Renders the client component.

| Parameter  | Type                                                          | Description                   |
| ---------- | ------------------------------------------------------------- | ----------------------------- |
| **config** | [Object](https://docs.microsoft.com/dotnet/api/system.object) | Dynamic configuration object. |

### ![](/files/hsR4ok3152WyAf8J2C1u) Show()

Shows the main menu.

### ![](/files/hsR4ok3152WyAf8J2C1u) Update()

Updates the component on the client. Overridden to update the owner form.

## Events

### ![](/files/hsR4ok3152WyAf8J2C1u) BackColorChanged

[EventHandler](https://docs.microsoft.com/dotnet/api/system.eventhandler) Fired when the [BackColor](#backcolor) property value changes.

### ![](/files/hsR4ok3152WyAf8J2C1u) CausesValidationChanged

[EventHandler](https://docs.microsoft.com/dotnet/api/system.eventhandler) Fired when the value of the [CausesValidation](#causesvalidation) property changes.

### ![](/files/hsR4ok3152WyAf8J2C1u) EnabledChanged

[EventHandler](https://docs.microsoft.com/dotnet/api/system.eventhandler) Fired when the [Enabled](#enabled) property value has changed.

### ![](/files/hsR4ok3152WyAf8J2C1u) FontChanged

[EventHandler](https://docs.microsoft.com/dotnet/api/system.eventhandler) Fired when the [Font](#font) property value changes.

### ![](/files/hsR4ok3152WyAf8J2C1u) ForeColorChanged

[EventHandler](https://docs.microsoft.com/dotnet/api/system.eventhandler) Fired when the [ForeColor](#forecolor) property value changes.

### ![](/files/hsR4ok3152WyAf8J2C1u) VisibleChanged

[EventHandler](https://docs.microsoft.com/dotnet/api/system.eventhandler) Fired when the [Visible](#visible) property value changes.

## Implements

| Name                                                                              | Description                                                                                                     |
| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| [IUserData](/api/wisej.web/interfaces/wisej.web.iuserdata.md)                     | Provides access to the `UserData` and `Tag` properties associated to the component implementing this interface. |
| [IBindableComponent](/api/wisej.web/data-binding/wisej.web.ibindablecomponent.md) | Bindable components implement this interface.                                                                   |
| [IWisejComponent](/api/wisej.core/interfaces/wisej.core.iwisejcomponent.md)       | All wisej components implement this interface.                                                                  |
| [IWisejSerializable](/api/wisej.core/interfaces/wisej.core.iwisejserializable.md) | Allows an object to serialize itself.                                                                           |


---

# 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/api/wisej.web/menus/wisej.web.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.
