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. 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 System.Windows.Forms.DataGridView.SortCompare event or by implementing the IComparer interface.
Reference
- DataGridView
Provides reference documentation for the DataGridView control.
- System.Windows.Forms.DataGridView.Sort
Provides reference documentation for the Sort method.
- System.Windows.Forms.DataGridViewColumn.SortMode
Provides reference documentation for the SortMode property.
- DataGridViewColumnSortMode
Provides reference documentation for the DataGridViewColumnSortMode enumeration.
See Also
Concepts
Column Types in the Windows Forms DataGridView Control