下面的示例代码演示了如何对 DepartmentBudget 列应用排序。 通过 TreeListColumn.SortOrder 属性对数据排序。 为了避免过度更新,代码被封闭在 TreeList.BeginSortTreeList.EndSort 方法之间。

C#CopyCode image复制代码
using DevExpress.XtraTreeList.Columns;
//...
treeList1.BeginSort();
treeList1.Columns["Department"].SortOrder = SortOrder.Ascending;
treeList1.Columns["Budget"].SortOrder = SortOrder.Descending;
treeList1.EndSort();
Visual BasicCopyCode image复制代码
Imports DevExpress.XtraTreeList.Columns
' ...
TreeList1.BeginSort()
TreeList1.Columns("Department").SortOrder = SortOrder.Ascending
TreeList1.Columns("Budget").SortOrder = SortOrder.Descending
TreeList1.EndSort()