[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Collapse]Application UI Manager
   [Expand]Deferred Load
   [Expand]Interaction with Dock Panels
   [Collapse]Bar and Ribbon Merging
     Bar and Ribbon Merging
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Bar and Ribbon Merging

The Document Manager component supports the merging of RibbonControl and BarManager controls. When this feature is enabled, Bar Item Links contained within Documents are merged to corresponding Bars and Ribbon Page Groups within the parent form. You can find more info about Bar and Ribbon merging mechanics in the MDI Merging and Ribbon Merging topics.

In this topic, you will learn how to merge BarManager components within a Document Manager.

  1. Start Visual Studio and create a new Windows Forms Application project. Enter the project's name, choose the solution folder, and click OK.

  2. Find the Document Manager component in the toolbox and drop it onto the form. By default, the Document Manager applies the Tabbed View to display its Documents. You can change the current Document Manager View by clicking the Convert to... links within the Tasks menu, which is invoked by clicking the component's smart tag (see the figure below). For this example, you will use the Tabbed View, so leave the Convert to… settings unchanged and invoke the Document Manager designer by clicking the Run Designer link.

  3. Switch to the Documents section in the Main tab. Click Add New Document to create the required number of tabbed Documents.

  4. The Documents created in the previous step are empty. If you try to launch the app now, you will get the 'Deferred Loading Exception', which asks you to set the Document content. In this example, you will use a UserControl for the content. Right-click the project in the Visual Studio Solution Explorer window and select Add | New Item.

    In the invoked dialog, choose the User Control option, enter its name and click Add, to add it into the project. Rebuild your project and make sure no errors are present.

    Now you can set the User Control as the content for your Documents. To do so, handle the BaseView.QueryControl event. Refer to the Deferred Load topic for details.

  5. Drop the BarManager and RichEditControl components onto the User Control. Once dropped, the Bar Manager creates three child Bar objects - Main Menu, Status Bar and a regular Toolbar. We will not need the Main Menu bar, so select it and press the Delete key to remove it. To add items to the Toolbar and Status Bar, click the [Add] label within the required Bar and select the desired item type. Next, add two BarButtonItem objects to the Toolbar (Undo and Redo) and a BarStaticItem object to the Status Bar. The figure below displays the approximate result.

    To specify BarButtonItem actions, handle their BarItem.ItemClick events. Use the built-in RichEditControl's RichEditControl.Undo and RichEditControl.Redo methods.

    Finally, set the BarItem.Enabled property of the Undo and Redo buttons to false.

    These buttons will be enabled only after an end-user has modified text within the RichEditControl. To implement this behavior, handle the RichEditControl's TextChanged event.

  6. Now add the Bar Manager for the main application form and customize its bars. Refer to the previous step if you have any difficulties. The figure below illustrates the main application form with a customized Bar Manager.

  7. Finally, merge Bar Manager from the UserControl with the main form's BarManager. First, set the DocumentManager.RibbonAndBarsMergeStyle property to Always.

    Main Menus are merged automatically. All other Bar types - Status Bars and Toolbars - need to be merged manually. To do so, handle the BarManager.Merge and BarManager.UnMerge events of the main form's BarManager.

    The image below illustrates the result. The Undo and Redo buttons are merged to the main form's Toolbar, and the 'Page 1' static item is merged to the main form's Status Bar. This behavior persists when you float a Document or move it to another DocumentGroup.


In this sample, you can also see another Document Manager feature - Microsoft Visual Studio 2012-like behavior. When you click BarItemLinks within the main form's RibbonControl, child Documents do not loose their focus. In this example, the feature allows the 'Undo' and 'Redo' buttons to perform required operations exactly on the currently focused RichEditControl.

Expanded Complete Code

Is this topic helpful?​​​​​​​