BaseView.DocumentSelectorCustomSortItems Event
Allows you to manually sort documents and dock panels displayed within the Document Selector.
Namespace: DevExpress.XtraBars.Docking2010.Views
Assembly: DevExpress.XtraBars.v24.2.dll
Declaration
Event Data
The DocumentSelectorCustomSortItems event's data class is DevExpress.XtraBars.Docking2010.Views.DocumentSelectorCustomSortItemsEventArgs.
Remarks
To sort a document selector’s items manually, you need to create the IComparer class descendant and override its Compare method. This method compares two items and returns -1, 0 or 1 depending on the result. This method will be used to compare all documents or dock panels within the document selector. Then, assign this custom comparer to the e.DockPanelComparer or e.DocumentComparer property to use it for dock panel or document sorting respectively.
The following code illustrates how to sort dock panels by their captions in reverse alphabetical order. The result is shown in the image below.
public partial class myApplicationForm : DevExpress.XtraEditors.XtraForm {
public frmMain() {
InitializeComponent();
tabbedView.DocumentSelectorProperties.ItemSortMode = Docking2010.Customization.ItemSortMode.Custom;
}
//. . .
private void tabbedView_DocumentSelectorCustomSortItems(object sender, DocumentSelectorCustomSortItemsEventArgs e) {
e.DockPanelComparer = new DescendingPanelTextComparer();
}
}
public class DescendingPanelTextComparer : IComparer<DockPanel> {
public int Compare(DockPanel panel1, DockPanel panel2) {
if (string.Equals(panel1.Text, panel2.Text)) return 0;
if (panel1.Text.CompareTo(panel2.Text) == 1) return -1;
else return 1;
}
}
Note
The DocumentSelectorCustomSortItems event fires only if the View’s DocumentSelectorProperties.ItemSortMode property equals Custom.