BarManager.MainMenu Property

Gets or sets the main menu bar.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v20.1.dll


public virtual Bar MainMenu { get; set; }
Public Overridable Property MainMenu As Bar

Property Value

Type Default Description


A Bar object representing the main menu bar. null (Nothing in Visual Basic) if no main menu is owned by this BarManager.


The MainMenu property allows you to specify the main menu for the container (form). For this purpose, assign a bar to this property. Such a bar automatically acquires specific properties:

  • It cannot be hidden by an end-user at runtime;
  • It's stretched horizontally, by default, to fit the container's width (see BarOptions.UseWholeRow);
  • The item multi-line arrangement feature is enabled by default (see BarOptions.MultiLine);
  • It receives focus when an end-user presses the ALT key;
  • If it belongs to an MDI child window, it is automatically merged with the parent MDI form's main menu.

To dock a bar to a specific container's edge, use the Bar.DockStyle property. The Bar.CanDockStyle property allows you to specify possible dock positions for the bar. For instance, you can set this property to BarCanDockStyle.Top and so prevent the bar from being docked to other container's edges, and from making it floating.

There can be only one main menu on the form.

See Also