Skip to main content
All docs
V23.2

RowProperties.SortOrder Property

Gets or sets whether the row data is sorted in ascending or descending order.

Namespace: DevExpress.XtraVerticalGrid.Rows

Assembly: DevExpress.XtraVerticalGrid.v23.2.dll

NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid

Declaration

[DefaultValue(ColumnSortOrder.None)]
[XtraSerializableProperty]
public ColumnSortOrder SortOrder { get; set; }

Property Value

Type Default Description
ColumnSortOrder None

A row sort order.

Available values:

Name Description
None

No sorting is applied to a column.

Ascending

Sorts the column in ascending order.

Descending

Sorts the columns in descending order.

Remarks

A user can sort data in the control from a row header’s context menu. Right-click a row header and select Sort Ascending or Sort Descending to sort values in the corresponding order. To make all rows display data in the same order as the data source, select Clear Sorting.

Vertical Grid Sorting

You can set the AllowSort property to false to disable this functionality.

Sort with a Click on a Row Header

You can enable the control’s AllowSortOnClick option to sort data when users click on a row header. Consecutive clicks change the sort order. Ctrl+Click clears the sort. If the AllowSort option is disabled, this property is not in effect.

If the control’s AllowSortOnClick option is enabled, you can use a row’s AllowSortOnClick property to disable this functionality for the row.

Sort in Code

Use a row’s SortOrder property to specify whether the row is sorted in ascending or descending order. If this property is set to None, data is not sorted. To make all rows display data in the same order as the data source, call the ClearSorting() method.

Sort by Multiple Rows

Data in the control can be sorted by multiple rows. For example, in a list of employees, you can first sort employees by surname and then by name. The resulting order of records depends on which list is sorted first. Users can hold Shift and click headers to sort by multiple rows.

A row’s SortIndex property specifies the index of the row in the collection of rows by which data is sorted. If you assign a non-negative value to this property, the control inserts the row to the collection of sorted rows at the specified position and sorts data in the row in ascending order.

When a user sorts data or you change a row’s SortOrder or SortIndex property value, the control raises the StartSorting event. When data is sorted, the EndSorting event fires.

Prevent Multiple Updates

Each time the sort order changes, the control reloads data from the data source. If you sort data by multiple rows, use the BeginSort() and EndSort() methods to prevent multiple updates. These methods suppress the StartSorting and EndSorting events.

Localize Context Menu Commands

You can use localizer objects to change captions of the control’s context menu commands. To do this, create a VGridLocalizer descendant, and override its GetLocalizedString method.

You can also use satellite assemblies to localize the control. See the following topic for more information: Localization.

Example

The code below shows how to sort data in code. If you sort data by multiple rows, call the BeginSort() and EndSort() methods to prevent multiple updates.

vGridControl.BeginSort();
erModelPrice.Properties.SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
erDiscount.Properties.SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
vGridControl.EndSort();
See Also