The requested page is not available for the requested platform. You are viewing the content for Default platform.

Sort Data (Runtime Sample)

This sample demonstrates how to sort report data at runtime. In the report created in this example, products are sorted by their names in ascending order:


To sort a report's data in code, create a GroupField object and add it to the DetailBand.SortFields collection in the report's XRControl.BeforePrint event handler.

using System;
using System.Drawing;
using DevExpress.XtraReports.UI;
// ...

private void XtraReport1_BeforePrint(object sender, Printing.PrintEventArgs e) {
    Detail.SortFields.Add(new GroupField("ProductName", XRColumnSortOrder.Ascending));

See Sort Data by a Custom Field to learn how to implement custom logic for sorting report data.