Skip to main content
A newer version of this page is available. .

ColumnView.SortInfo Property

Provides access to the collection of sorted and grouping columns within the current View.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v19.1.dll


[XtraSerializableProperty(XtraSerializationFlags.UseAssign | XtraSerializationFlags.LoadOnly, 1000)]
public virtual GridColumnSortInfoCollection SortInfo { get; }

Property Value

Type Description

A GridColumnSortInfoCollection collection containing information on the sorted and grouping columns within the View.


The SortInfo property can be used to apply sorting and grouping to one or more of the columns in the current View. This property represents a collection of GridColumnSortInfo objects. Each such element specifies a column, the sort order and a grouping flag, which is set to true if grouping is applied to this column.

To apply sorting or grouping to a column(s), use the appropriate methods provided by the GridColumnSortInfoCollection class. In most cases you will use the overloads of the GridColumnSortInfoCollection.AddRange and GridColumnSortInfoCollection.ClearAndAddRange methods to apply sorting or grouping. See the GridColumnSortInfoCollection topic for more information.

As in Grid Control version 2 to apply sorting to a column the column’s GridColumn.SortOrder property can still be used. The GridColumn.GroupIndex property is an alternative way to apply grouping to the column.

The column’s GridColumn.SortMode property specifies how the column is sorted (by display text, value or custom sorting).


The following example shows how to apply sorting and grouping to columns via the ColumnView.SortInfo collection. The columns which will be used to group and sort data are added using the GridColumnSortInfoCollection.ClearAndAddRange method. This method first clears the collection. The method’s integer parameter determines the number of the specified array’s elements that will be used to group data. In this example this parameter is set to 2 and thus the two first elements (CategoryID and SupplierID) will be used to group data. The third element (ProductName) refers to the column against which only sorting is applied.

using DevExpress.Data;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Grid;
// ...
GridView view = gridControl1.MainView as GridView;
GridColumnSortInfo [] sortInfo = { 
        new GridColumnSortInfo(view.Columns["CategoryID"], ColumnSortOrder.Ascending), 
        new GridColumnSortInfo(view.Columns["SupplierID"], ColumnSortOrder.Descending),
        new GridColumnSortInfo(view.Columns["ProductName"], ColumnSortOrder.Ascending)
view.SortInfo.ClearAndAddRange(sortInfo, 2);
See Also