Skip to main content

Add and Remove Toolbars

  • 4 minutes to read

This document describes existing toolbar types and how to add them.

Initial Setup

  • Locate the BarManager component in the VS Toolbox and drop it onto the form. The Bar Manager is the core component of the DevExpress Bars library and provides centralized access to all toolbars, menus and items.
  • The BarManager automatically creates three toolbars - main menu, regular toolbar and status bar.

    Bars - Initial Bar Layout

    All three toolbars are objects of the same Bar class, but nevertheless feature severe differences in appearance and behavior.

    • Main menu. A Bar assigned to the bar manager’s BarManager.MainMenu property. This bar contains buttons with no images. Each button is a category (e.g., ‘File’, ‘Edit’, ‘Format’) that displays other buttons and sub-items on clicking. This bar has the following specifics:

      • it cannot be hidden by an end-user at runtime;
      • it’s stretched by default horizontally to fit the container’s width (see the BarOptions.UseWholeRow property);
      • the item multi-line arrangement feature is enabled by default (see the BarOptions.MultiLine property);
      • 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.
    • Status bar. A Bar assigned to the manager’s BarManager.StatusBar property. Designed to display status application info; provides the following specific features:

    • Regular toolbar. A Bar that contains buttons and editors that represent the most frequently used actions (e.g., creating new documents, font settings or text alignment). Buttons within such bars usually display their icons only. Can occupy multiple lines (see the BarOptions.MultiLine property) or less than one (see the BarOptions.UseWholeRow property).

Add and Remove Toolbars

To remove a bar, first click it at design-time. The selected bar will become highlighted.

Bars - Selected Bar

Press the “DELETE” key to remove the selected bar.

To add a bar, invoke the BarManager’s smart tag and click “Create Toolbar”.

Bars - Add Toolbar

Another way to add a toolbar is to invoke the BarManager component’s smart tag and click “Customize”. This will invoke the Customization Window dialog where you can add and remove toolbars, as well as reset their settings to default values.

Bars - Add Toolbar (Customization Window)

The added Bar will be a regular toolbar, docked below other toolbars of this type. You can instantly re-arrange bars by dragging them at design time.

Bars - Dragging Bars

Code Sample

public void InitializeBars() {
    BarManager bManager = new BarManager();
    bm = bManager;
    bManager.Form = this;
    //All bar modifications should be performed between the BeginUpdate and EndUpdate method calls
    //Create three toolbars
    Bar mainBar = new Bar(bm, "Main Menu") { DockStyle = BarDockStyle.Top, DockRow = 0 };
    Bar statusBar = new Bar(bm, "Status Bar") { DockStyle = BarDockStyle.Bottom };
    Bar toolbar1 = new Bar(bm, "File Toolbar") { DockStyle = BarDockStyle.Top };
    //Set the existing Bar Manager as your bars' parent
    bManager.Bars.AddRange(new Bar[] { mainBar, statusBar, toolbar1 });
    //Choose main menu and status bars
    bManager.MainMenu = mainBar;
    bManager.StatusBar = statusBar;

You can access created toolbars by their Bar.BarName property values.

var bar = barManager1.Bars["Image Toolbar"];
See Also