Skip to main content
A newer version of this page is available. .

Adding a Title Page to a Report

  • 3 minutes to read

This tutorial illustrates how to add a title page to a report and consists of the following sections.

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.

Most reports you create are platform-agnostic, which means that you can use them later in applications created on any of the supported platforms. To learn more about storing and reusing your reports, see CodeDOM Serialization.

Add a Title Page to the Report

  • In the PROJECT menu, choose Add New Item… (or press CTRL+SHIFT+A) to invoke the Add New Item dialog. In this dialog, select the DevExpress v17.2 Report Wizard item.

    Set the report name to XtraReport2 and click Add.

    add-a-new-report-winforms-report-wizard

    In the invoked XtraReport Wizard, select Empty Report and click Finish.

    report-wizard-add-empty-report

    Drop an XRLabel onto the report’s Detail band.

    toolbox-drop-report-control-label

  • Switch to the Field List and right-click the Parameters item. In the invoked context menu, select Add Parameter.

    parameters-add-blank-data-source

  • In the Add New Parameter dialog, set the Parameter.Name property to paramPaymentDate and the Parameter.Type property to DateTime. Since this parameter is for internal use only, disable the Show in the parameters panel option.

    parameters-title-report-page

  • Double-click the XRLabel and set its Text property to “Products Report for [Parameters.paramPaymentDate]“.

    title-report-page-xrlabel

  • To apply a format string to the parameter, invoke XRLabel smart-tag and define the Format String as {0:MMMM, yyyy}.

    title-report-page-format

  • Before merging the pages of the two reports together, the input reports need to be generated.

    After the original reports are generated, you can access each report’s collection of pages, and insert pages from each generated document to build a merged report. You can manage this process in the XRControl.AfterPrint event, raised after the XtraReport is generated.

    using System;
    // ...
    
    private void ManagementReport_AfterPrint(object sender, EventArgs e) {   
        //Create a new instance of the title report
        XtraReport2 titleReport = new XtraReport2();
        // Assign its paramPaymentDate parameter value
        titleReport.Parameters["paramPaymentDate"].Value = DateTime.Today;
        // Generate the report document
        titleReport.CreateDocument();
    
        // Enable this property to maintain continuous page numbering
        this.PrintingSystem.ContinuousPageNumbering = true;
        // Insert the page from title report into the beginning of the Management Report
        this.Pages.Insert(0, titleReport.Pages[0]);            
    }
    

Preview and Publish the Report

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

title-report-page-result