Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataGridView::SortedColumn Property

 

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

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

public:
[BrowsableAttribute(false)]
property DataGridViewColumn^ SortedColumn {
	DataGridViewColumn^ 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.

System_CAPS_noteNote

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
Show:
© 2017 Microsoft