Export (0) Print
Expand All

BindingSource::Sort Property

Gets or sets the column names used for sorting, and the sort order for viewing the rows in the data source.

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

public:
property String^ Sort {
	String^ get ();
	void set (String^ value);
}

Property Value

Type: System::String
A case-sensitive string containing the column name followed by "ASC" (for ascending) or "DESC" (for descending). The default is nullptr.

The Sort property is a case-sensitive string that specifies the column names used to sort the rows, along with the sort direction. Columns are sorted ascending by default. Multiple columns can be separated by commas, such as "State, ZipCode DESC".

To support sorting, the underlying list must implement the IBindingList or IBindingListView interfaces. This capability can be queried through the SupportsSorting property. Multicolumn sorting is available when the SupportsAdvancedSorting property is true.

Setting the Sort property will change the internal list depending on its type:

The internal list's sort properties are only changed when the sort string is not nullptr. The get accessor for this property will not retrieve the sort value of the internal list; instead, it will return the set accessor value. The value of the Sort property will persist when the data source changes.

The following example shows how to use the Sort property to perform basic sorting with a DataView. To run this example, paste the code into a Windows Form and call PopulateDataViewAndSort from the form's constructor or Load event-handling method. Your form should import the System.Xml and System.IO namespaces.

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

The following example shows how to use the Sort property to perform advanced sorting with a DataView. To run this example, paste the code into a Windows Form and call PopulateDataViewAndAdvancedSort from the form's constructor or Load event-handling method. Your form should import the System.Xml and System.IO namespaces.

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

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft