From Xojo Documentation

Revision as of 19:17, 23 July 2021 by Gperlman (talk | contribs)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Class (inherits from DesktopMenuItem)

New in 2021r3

Used to handle the application’s and windows’ menu bar.

LastRowIndex fa-lock-32.png Tag
Name Text

AddMenu Count RemoveMenuAt
AddMenuAt Handle
Close MenuAt


When you create a new desktop project, a default MenuBar (called MainMenuBar) is added to your project.

You can refer to a MenuBar globally by its name because an "implicit instance" is automatically created for you to use. If you use the global name, then you will get the same MenuBar instance everywhere you use it. If you modify the MenuBar in code, the modification will appear everywhere the MenuBar is used.

If you would rather have separate instances of the MenuBar, you should assign it in code manually in the DesktopWindow.Opening event:

Self.DesktopMenuBar = New MainMenuBar

On macOS, if a window does not have a MenuBar specified, then the window uses the MenuBar specified on DesktopApplication.MenuBar.

On Windows and Linux, if a window does not have a MenuBar specified, then the window will display without a MenuBar even if one is specified in DesktopApplication.MenuBar.


See examples for the DesktopMenuItem class.

See Also

DesktopMenuItem; DesktopApplication.MenuBar and DesktopWindow.MenuBar properties.