Back to Devexpress

ToolbarFormControl.Merge Event

windowsforms-devexpress-dot-xtrabars-dot-toolbarform-dot-toolbarformcontrol-d5dae8e3.md

latest3.4 KB
Original Source

ToolbarFormControl.Merge Event

Fires after title bars are merged.

Namespace : DevExpress.XtraBars.ToolbarForm

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Merge")]
public event ToolbarFormMergeEventHandler Merge
vb
<DXCategory("Merge")>
Public Event Merge As ToolbarFormMergeEventHandler

Event Data

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

PropertyDescription
MergedChildProvides access to the child form’s title bar.
MergeOwnerProvides access to the parent form’s title bar.

Remarks

In an MDI application, when a child toolbar form is maximized, its bar items in the title bar are merged with the parent form’s bar items. Use the MdiMergeStyle property to specify whether bar items are merged when a child form is maximized, focused, or never merged.

The parent and child title bars fire the Merge and UnMerge events after the bar items are merged.

Example

If the parent form and a child form contain bar items with equal captions (for example, File ), you can remove the duplicated command from the merged title bar as the code below demonstrates.

csharp
private void ToolbarFormControl1_Merge(object sender, DevExpress.XtraBars.ToolbarForm.ToolbarFormMergeEventArgs e) {
    e.MergeOwner.TitleItemLinks
        .GroupBy(x => x.Caption)
        .Where(x => x.Count() > 1)
        .ForEach(x => x
        .ForEach(y => {
            if (e.MergedChild.TitleItemLinks.Where(z => z.Item == y.Item).Count() != 0)
                y.Visible = false;
        }));
}
vb
Private Sub ToolbarFormControl1_Merge(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ToolbarForm.ToolbarFormMergeEventArgs) _
    Handles toolbarFormControl1.Merge
    e.MergeOwner.TitleItemLinks.GroupBy(Function(x) x.Caption).Where(Function(x) x.Count() > 1).ForEach(Sub(x) x.ForEach(Sub(y)
        If e.MergedChild.TitleItemLinks.Where(Function(z) z.Item.Equals(y.Item)).Count() <> 0 Then
            y.Visible = False
        End If
    End Sub))
End Sub

See Also

UnMerge

MdiMergeStyle

ToolbarFormControl Class

ToolbarFormControl Members

DevExpress.XtraBars.ToolbarForm Namespace