GridControl.SortBy(GridColumn, ColumnSortOrder, Int32) Method
Sorts data against the specified column and arranges it according to the sort order. The position of the sort condition within the GridSortInfoCollection depends on the sortedIndex parameter.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v24.2.dll
NuGet Package: DevExpress.Wpf.Grid.Core
#Declaration
public void SortBy(
GridColumn column,
ColumnSortOrder sortedOrder,
int sortedIndex
)
#Parameters
Name | Type | Description |
---|---|---|
column | Grid |
A column within the Grid |
sorted |
Column |
Sort order of the specified column. |
sorted |
Int32 | The index of the specified sort condition within the Grid |
#Remarks
The GridControl allows you to sort data against multiple columns. Call the SortBy method to apply a new sort condition. The GridControl creates a new GridSortInfo object that stores sort parameters, and appends this object to the GridSortInfoCollection. The sort operation result depends on the order of the applied conditions within the collection. If the GridSortInfoCollection already contains a sort condition for the specified column, the GridControl replaces this condition with a new condition.
If the sortedIndex parameter exceeds the index of the last element within the GridSortInfoCollection, the GridControl appends the GridSortInfo object to the collection. Pass a negative value as the sortedIndex parameter to remove the applied sort condition.
Refer to the following topics for more information: Sorting in Code and Sort Data.