Step 3 - Bar Manager

  • 3 minutes to read

In this step, you will add a Bar Manager component to your application and learn how to interact with DocumentManager and DockManager items via BarItems. You may want to replace a Bar Manager with a Ribbon Control. All of the instructions below are suitable for the Ribbon Control as well. However, in this step the Bar Manager control is used, as it is more appropriate for the Visual Studio application UI.

  1. Locate the Bar Manager component in your toolbox and drop it onto the form.

    DockingUI - Add BarManager

  2. Once you add the Bar Manager control, three bars are created automatically. These bars represent the main menu, status bar and regular toolbar. Technically, these bars are the same Bar objects that can display BarItemLinks, but the main menu bar and status bar are assigned to the BarManager.MainMenu and BarManager.StatusBar properties, respectively. The following image illustrates these bars (a BarStaticItem was added to each bar for visualization purposes).

    DockingUI - Default Bars

    To add new bars, use the corresponding link in the Bar Manager smart tag.

    DockingUI - Add Toolbar

    To delete an existing bar, select it at design time and press 'Delete', or click the corresponding button in the Bar Manager Designer. For this example we will only need the main menu and status bar, so the regular bar can be deleted.

    DockingUI - Delete Toolbar

  3. Bars display BarItemLink objects - links to BarItems. To add a BarItem to a desired Bar, click the 'Add' button and select the required BarItem type. Add a BarSubItem to your main menu Bar.

    DockingUI - Add BarItem

    You can right-click an item to customize it. For example, choose a style that specifies whether only an item caption, item glyph or both caption and glyph should be displayed. To specify this style in code use the BarItemLink.PaintStyle property.

    DockingUI - Customize BarItem

    By default, items within regular toolbars only display icons, and items within the main menu only display captions.

  4. The BarStaticItem that you added in the previous step is a submenu that can contain other items. To add a BarItem to a BarStaticItem, select the BarStaticItem and click the Add button (using the same approach you used when adding items to a Bar). Add the New BarButtonItem to the File submenu. This button will add a new Document to your application. Refer to the Documents topic to see an example of adding Documents to a DocumentManager at runtime.
  5. Add a BarDockingMenuItem to your main menu. This unique item allows you to manage both DockPanels and Documents contained in your application.

    DockingUI - BarDockingMenuItem

The animation below shows the approximate results of completing the steps above.

DockingUI - Result Animation

To learn more about the controls used in this tutorial, refer to the following help topics.

See Also