GridControl.SortBy(GridColumn, ColumnSortOrder, Int32) Method

Sorts data by the values of the specified column in the specified order, and places the column to the specified position among the sorted columns.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v20.1.dll

Declaration

public void SortBy(
    GridColumn column,
    ColumnSortOrder sortedOrder,
    int sortedIndex
)
Public Sub SortBy(
    column As GridColumn,
    sortedOrder As ColumnSortOrder,
    sortedIndex As Integer
)

Parameters

Name Type Description
column GridColumn

A GridColumn object that represents the column within the grid.

sortedOrder ColumnSortOrder

A ColumnSortOrder enumeration value that specifies the column's sort order.

sortedIndex Int32

An integer value that specifies the zero-based column's index among the sorted columns.

Remarks

The DXGrid control allows data sorting by multiple columns. Any previous sorting is not cleared when calling the SortBy method.

If the grid's data isn't sorted by the specified column, the SortBy method sorts data by its values in the specified order. The new sort order applies an additional sorting condition to the one previously applied. The grid creates a new GridSortInfo object with the specified settings and inserts it into the GridControl.SortInfo collection at the position specified by the sortedIndex parameter. If this parameter is negative, or exceeds the index of the last element within the GridControl.SortInfo collection, the GridSortInfo object is appended to the collection.

End-users are allowed to sort data if the view's DataViewBase.AllowSorting property is set to true.

To learn more, see Sorting in Code and Sorting.

See Also