Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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.