Skip to main content

Sort Data (Runtime Sample)

This code sample demonstrates how to sort report data at runtime. In this example, the report’s DetailBand is bound to the Products table of the sample Northwind database. The products are sorted by their names in ascending order:

How to Sort Data at Rutime

To sort report data in code, create the GroupField object and add it to the DetailBand.SortFields collection:

using DevExpress.XtraReports.UI;
// ...
    TestReport rep = new TestReport();
    DetailBand detail = rep.Bands[BandKind.Detail] as DetailBand;
    detail.SortFields.Add(new GroupField("ProductName"));

You can use the calculated field to implement custom logic to sort the report data. For more information, review the following help topic: Sort Data by Custom Criteria.