Sorting data in the Windows Forms DataGridView control
By default, users can sort the data in a DataGridView control by clicking the header of a text box column (or by pressing F3 when a text box cell is focused on .NET Framework 4.7.2 and later versions). You can modify the SortMode property of specific columns to allow users to sort by other column types when it makes sense to do so. You can also sort the data programmatically by any column, or by multiple columns.
In this section
Column Sort Modes in the Windows Forms DataGridView Control
Describes the options for sorting data in the control.
How to: Set the Sort Modes for Columns in the Windows Forms DataGridView Control
Describes how to enable users to sort by columns that are not sortable by default.
How to: Customize Sorting in the Windows Forms DataGridView Control
Describes how to sort data programmatically and how to customize sorting by using the DataGridView.SortCompare event or by implementing the IComparer interface.
Provides reference documentation for the DataGridView control.
Provides reference documentation for the Sort method.
Provides reference documentation for the SortMode property.
Provides reference documentation for the DataGridViewColumnSortMode enumeration.
Submit and view feedback for