Bar

BarManager.UnMerge Event

Allows you to customize menus and bars when a child MDI form becomes inactive or when it is restored or minimized from its maximized view (depending on the BarManager.MdiMenuMergeStyle property value).

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v20.1.dll

Declaration

[DXCategory("Events")]
public event BarManagerMergeEventHandler UnMerge
<DXCategory("Events")>
Public Event UnMerge As BarManagerMergeEventHandler

Event Data

The UnMerge event's data class is BarManagerMergeEventArgs. The following properties provide information specific to this event:

Property Description
ChildManager Gets the Bar Manager of a child MDI form for which the merge mechanism is invoked.

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 Manager.

The merge mechanism is invoked according to the BarManager.MdiMenuMergeStyle property of the Bar Manager residing in the parent form. This property allows you to disable merge operations and enable them when a child form is activated or maximized. Similarly, corresponding unmerge operations will occur when a child form becomes inactive or when it is restored or minimized from its maximized view.

Use the BarManager.Merge event to perform specific actions when a merge mechanism is invoked. Usually, you handle this event to manually merge specific bars belonging to parent and child MDI forms (the main menus are merged and unmerged automatically). The UnMerge event allows you to undo the results of the previous manual merge operation. This event is fired by the unmerge mechanism according to BarManager.MdiMenuMergeStyle.

To merge and unmerge two bars, use the Bar.Merge and Bar.UnMerge methods.

Refer to the MDI Merging document for more information.

Examples

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();
}
See Also