Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

IBaseDocumentSelectorProperties.ItemSortMode Property

Gets or sets order in which Documents and dock panels appear inside the Document Selector.

Namespace: DevExpress.XtraBars.Docking2010.Customization

Assembly: DevExpress.XtraBars.v24.2.dll

NuGet Package: DevExpress.Win.Navigation

#Declaration

ItemSortMode ItemSortMode { get; set; }

#Property Value

Type Description
DevExpress.XtraBars.Docking2010.Customization.ItemSortMode

An ItemSortMode enumeration value that specifies the order in which Documents and dock panels appear inside the Document Selector.

#Remarks

The Document Selector stores the Document (and dock panel) activation sequences and arranges its items in the opposite direction. The figure below illustrates the order in which Document Manager’s Documents were activated, and how the Document Selector arranges them.

Document Manager - Document Selector Queue

To change this default order, set the ItemSortMode property to either Alphabetical or Custom. In custom sorting mode, handle the BaseView.DocumentSelectorCustomSortItems event and assign your custom IComparer<BaseDocument> object to the e.DocumentComparer object. You can also create a separate dock panel container and assign it to the e.DockPanelComparer property.

The code sample below illustrates how to implement the custom item order the order in which Documents appear on-screen.

using DevExpress.XtraBars.Docking2010.Views;
// . . .
tabbedView1.DocumentSelectorProperties.ItemSortMode = DevExpress.XtraBars.Docking2010.Customization.ItemSortMode.Custom;
tabbedView1.DocumentSelectorCustomSortItems += TabbedView1_DocumentSelectorCustomSortItems;

private void TabbedView1_DocumentSelectorCustomSortItems(object sender, DevExpress.XtraBars.Docking2010.Views.DocumentSelectorCustomSortItemsEventArgs e) {
    e.DocumentComparer = new DirectOrderComparer(tabbedView1);
}

// Custom Document comparer

public class DirectOrderComparer : IComparer<BaseDocument> {
    BaseView viewCore;
    List<BaseDocument> activationOrder;
    public DirectOrderComparer(BaseView view) {
        viewCore = view;
        if (view.ActiveDocument == null) return;
        FillActivationOrder(view);
    }
    void FillActivationOrder(BaseView view) {
        activationOrder = new List<BaseDocument>();
        activationOrder.Add(view.ActiveDocument);
        for (int i = view.Documents.IndexOf(view.ActiveDocument) + 1; i < view.Documents.Count; i++) {
            activationOrder.Add(view.Documents[i]);
        }
        for (int i = 0; i < view.Documents.IndexOf(view.ActiveDocument); i++) {
            activationOrder.Add(view.Documents[i]);
        }
        foreach (var item in view.FloatDocuments) {
            activationOrder.Add(item);
        }
    }
    public int Compare(BaseDocument x, BaseDocument y) {
        int xIndex = activationOrder.IndexOf(x);
        int yIndex = activationOrder.IndexOf(y);
        return xIndex.CompareTo(yIndex);
    }
}
See Also