Limit the Number of Records per Group

This tutorial describes how to display a specific number of records in each report group.

Create a Reporting Application

To get started with this tutorial, open an existing reporting application or create a new one from scratch. To learn how to create a reporting application on the platform of your choice, see Adding a Report to Your .NET Application.

The report created in this tutorial will be platform-agnostic, which means that you can use it later in applications created on any supported platform. See Store and Distribute Reports to learn more about storing and reusing reports.

Limit the Number of Records in Groups

  1. To limit the number of records in report groups, use the report created in the following tutorial: Group and Sort a Report's Data.
  2. Handle the XRControl.BeforePrint event of the Detail and Group Header bands and specify the number of records to display in each group.

    using System.Drawing.Printing;
    // ...
    
    private int detailRowCount = 0;
    
    private void Detail_BeforePrint(object sender, PrintEventArgs e) {
        if (++detailRowCount > 5)
            e.Cancel = true;
    }
    
    private void GroupHeader1_BeforePrint(object sender, PrintEventArgs e) {
        detailRowCount = 0;
    }
    

Preview and Publish the Report

Your report is now ready to be generated. Create a Print Preview to view the result.

group-records-limit