A newer version of this page is available. Switch to the current version.

GridColumnSortInfoCollection.Add(GridColumn, ColumnSortOrder) Method

Adds a new GridColumnSortInfo item to the collection.

Namespace: DevExpress.XtraGrid.Columns

Assembly: DevExpress.XtraGrid.v19.2.dll


public GridColumnSortInfo Add(
    GridColumn column,
    ColumnSortOrder sortOrder


Name Type Description
column GridColumn

A GridColumn object which will be sorted using the specified sort order. This parameter's value is used to initialize the GridColumnSortInfo.Column property.

sortOrder ColumnSortOrder

A ColumnSortOrder value specifying the sort order for the column. This parameter's value is used to initialize the GridColumnSortInfo.SortOrder property.


Type Description

A GridColumnSortInfo object representing the new element in the collection; null if the object cannot be added to the collection.


Adding an element to the collection automatically applies sorting by the corresponding column.

This method returns null if the specified element cannot be added to the collection. This can occur for several reasons:

  • the grid's View doesn't support grouping and the specified column is being inserted as a grouping column (at a position less than the GridColumnSortInfoCollection.GroupCount);
  • the specified column doesn't support sorting and therefore grouping (for instance, the columns which display image or memo data);
  • another element which refers to the specified column is already present in the current collection.
See Also