Gets or sets how the group is sorted.

Namespace:  C1.C1Report
Assembly:  C1.C1Report.2 (in C1.C1Report.2.dll)

Syntax

C#
[DefaultValueAttribute(SortEnum.NoSort)]
public SortEnum Sort { get; set; }
Visual Basic
<DefaultValueAttribute(SortEnum.NoSort)> _
Public Property Sort As SortEnum
	Get
	Set

Remarks

The specified sorting is applied to the content of the GroupBy property. For example, if GroupBy contains the expression "FirstName" and Sort is set to "Ascending", then the group will be sorted in ascending order based on the content of the "FirstName" column in the data source.

Note that the sorting is performed by the data source itself, not by C1Report. Because of this, sorting is always based on column names rather than calculated expressions. If the GroupBy property contains a calculated expression, the component will extract the first column name from the expression and will sort based on that value. For example, if GroupBy is set to "Left(FirstName, 3)", the sorting will be based on the "FirstName" column, not on the first three characters of the first names.

This can present problems in a few cases, especially if you want to sort based on date parts (year, month, quarter). In these cases, the recommended procedure is to add a calculated column to the data source (by changing the SQL statement used to retrieve the data), then set the GroupBy property to the name of the calculated column.

The default value for this property is SortEnum.NoSort.

Examples

The code below uses a SQL statement to add a "HireQuarter" column to the data source, then sorts a group based on this new column. The report will show employees sorted by the quarter when they were hired.
Copy CodeC#
string sql = 
    "SELECT *, DATEPART('q', HireDate) AS HireQuarter " +
    "FROM Employees";
c1r.DataSource.RecordSource = sql;
c1r.Groups[0].GroupBy = "HireQuarter";
c1r.Groups[0].Sort = SortEnum.Ascending;

See Also