DataGridView.SortedColumn Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets the column by which the DataGridView contents are currently sorted.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

member SortedColumn : DataGridViewColumn with get

Property Value

Type: System.Windows.Forms.DataGridViewColumn

The DataGridViewColumn by which the DataGridView contents are currently sorted.

If the DataGridView is not sorted, this property will return null.

When the column indicated by this property has a SortMode property value of DataGridViewColumnSortMode.Automatic, it will display a sorting glyph based on the value of the SortOrder property.

When the column has a SortMode property value of DataGridViewColumnSortMode.Programmatic, you must display the sorting glyph yourself through the DataGridViewColumnHeaderCell.SortGlyphDirection property.


The value of this property is not meaningful when you sort the control using custom sorting. For more information about custom sorting, see the Sort(IComparer) method and the SortCompare event.

The following code example demonstrates how to use the SortedColumn property in a programmatic sort.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top