---
title: Sorting data in DataGridView control
ms.date: "02/13/2018"
helpviewer_keywords: 
  - "data [Windows Forms], sorting in grids"
  - "data grids [Windows Forms], sorting data"
  - "DataGridView control [Windows Forms], sorting data"
ms.assetid: c1d4f24c-d961-4181-809d-5a5caa6122e4
---
# Sorting data in the Windows Forms DataGridView control

By default, users can sort the data in a <xref:System.Windows.Forms.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 <xref:System.Windows.Forms.DataGridViewColumn.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](column-sort-modes-in-the-windows-forms-datagridview-control.md)  
Describes the options for sorting data in the control.

[How to: Set the Sort Modes for Columns in the Windows Forms DataGridView Control](set-the-sort-modes-for-columns-wf-datagridview-control.md)  
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](how-to-customize-sorting-in-the-windows-forms-datagridview-control.md)  
Describes how to sort data programmatically and how to customize sorting by using the <xref:System.Windows.Forms.DataGridView.SortCompare?displayProperty=nameWithType> event or by implementing the <xref:System.Collections.IComparer> interface.

## Reference

<xref:System.Windows.Forms.DataGridView>  
Provides reference documentation for the <xref:System.Windows.Forms.DataGridView> control.  

<xref:System.Windows.Forms.DataGridView.Sort%2A?displayProperty=nameWithType>  
Provides reference documentation for the <xref:System.Windows.Forms.DataGridView.Sort%2A> method.

<xref:System.Windows.Forms.DataGridViewColumn.SortMode%2A?displayProperty=nameWithType>  
Provides reference documentation for the <xref:System.Windows.Forms.DataGridViewColumn.SortMode%2A> property.

<xref:System.Windows.Forms.DataGridViewColumnSortMode>  
Provides reference documentation for the <xref:System.Windows.Forms.DataGridViewColumnSortMode> enumeration.

## See also

- [DataGridView Control](datagridview-control-windows-forms.md)
- [Column Types in the Windows Forms DataGridView Control](column-types-in-the-windows-forms-datagridview-control.md)
