Skip to main content

GroupHeaderBand Class

A report band used for specifying grouping criteria and displaying information at the beginning of a group of records.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v23.1.dll

NuGet Package: DevExpress.Reporting.Core


public class GroupHeaderBand :


Use the GroupHeaderBand.GroupFields property to specify grouping criteria for report data.


A corresponding GroupFooterBand should have the same GroupBand.Level property value as the group header.

See the following topics for more details:

See Laying out Dynamic Report Contents to learn about the layout options available for this band.


View Example: How to group data at runtime

The report created in this example uses the sample Northwind database.

The report is bound to the SQL data source, which retrieves data from the CategoryProducts database view.

This report contains two bands: the Detail band and the Group Header band. The Group Header band includes a group field that specifies that the data is grouped by the CategoryName data field.


You can handle the XRControl.BeforePrint event to change data grouping before a report is printed or previewed.

using System;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
using DevExpress.XtraReports.Configuration;
// ...

public XtraReport CreateDataGroupingReport() {
    // Create a report.
    XtraReport report = new XtraReport();

    // Create a data source with the specified connection parameters.  
    SQLiteConnectionParameters connectionParameters =
        new SQLiteConnectionParameters() {
                    FileName = "nwind.db",
                    Password = null
    SqlDataSource ds = new SqlDataSource(connectionParameters);   
    CustomSqlQuery query = new CustomSqlQuery();
    query.Name = "customQuery";
    query.Sql = "SELECT * FROM CategoryProducts";

    // Assign the data source to the report.
    report.DataSource = ds;
    report.DataMember = "customQuery";

    // Create the Detail band and add it to the report.
    DetailBand detail = new DetailBand { HeightF = 40 };

    // Create the Group Header band and add it to the report.
    GroupHeaderBand ghBand = new GroupHeaderBand { HeightF = 40 };

    // Create a GroupField instance and add it to the Group Header band.
    GroupField groupField = new GroupField("CategoryName");

    // Create labels.
    XRLabel labelGroup = new XRLabel { ForeColor = System.Drawing.Color.Blue };
    XRLabel labelDetail = new XRLabel { LocationF = new System.Drawing.PointF(30, 0) };

    // Specify label bindings.
    labelGroup.ExpressionBindings.Add(new ExpressionBinding("BeforePrint", "Text", "[CategoryName]"));
    labelDetail.ExpressionBindings.Add(new ExpressionBinding("BeforePrint", "Text", "[ProductName]"));

    // Add the labels to the report's bands.    

    return report;
See Also