Skip to main content

Document Selector

  • 3 minutes to read

The Document Selector dialog allows end-users to switch between Documents and dock panels by pressing the following hot-keys:

  • Ctrl + Tab - switch to the previous document (hold “Ctrl” and press “Tab” repeatedly to navigate to previously active documents);
  • Ctrl + Shift + Tab - cycle through documents forward (i.e. in the direction opposite to the Ctrl+Tab navigation);
  • Left and Right arrows - toggle between the Document and panel navigation.

Document Manager - Document Selector

This dialog is supported in all Views except the WindowsUI View. To turn the Document Selector off, disable the BaseView.UseDocumentSelector setting.

Related API

Item Order

The Document Selector tracks the sequence in which end-users activate Documents and panels, and arranges its items in the reverse order so that a user moves back to previous panels when holding “Ctrl” and repeatedly pressing “Tab”. The figure below illustrates the order in which the 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 IBaseDocumentSelectorProperties.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 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);
    }
}