Bar.UnMerge() Method
Restores the links layout of the current bar after another bar has been merged with it.
Namespace: DevExpress.XtraBars
Assembly: DevExpress.XtraBars.v24.1.dll
NuGet Package: DevExpress.Win.Navigation
Declaration
Remarks
In an MDI application, XtraBars give you the ability to merge the bars of parent and child MDI forms, i.e. combine bar links belonging to different Bar Managers.
The merge mechanism is invoked according to the BarManager.MdiMenuMergeStyle property value. It allows you to disable merge operations, enable merging when a child form is activated or enable merging when a child form is maximized. For the last two mentioned options, the corresponding unmerge mechanism is invoked when an MDI child becomes inactive or when a child form is restored from its minimized or maximized view.
The UnMerge method restores the bar’s layout after the previous merge operation. Usually, you place the method call within an BarManager.UnMerge event handler.
See the Bar.Merge topic for more information.
Example
Assume you have parent and child MDI forms. On each one you place a Bar Manager and create an Edit toolbar. When the child MDI form is activated, we want to merge these toolbars (XtraBars supports automatic merging of main menus only). For this purpose, the BarManager.Merge event is handled. Toolbars are merged using the Bar.Merge method.
When the child form becomes inactive (for instance, focus may move to another form), we need to restore the original main menu layout of the parent form. For this purpose, the Bar.UnMerge
method is called in an BarManager.UnMerge event handler.
using DevExpress.XtraBars;
private void barManager1_Merge(object sender, BarManagerMergeEventArgs e) {
BarManager parentBarManager = sender as BarManager;
Bar childBar = e.ChildManager.Bars["Edit"];
Bar parentBar = parentBarManager.Bars["Edit"];
parentBar.Merge(childBar);
}
private void barManager1_UnMerge(object sender, BarManagerMergeEventArgs e) {
BarManager parentBarManager = sender as BarManager;
Bar parentBar = parentBarManager.Bars["Edit"];
parentBar.UnMerge();
}