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

How to: Merge the Pages of Two Reports

  • 3 min to read

This example demonstrates how to modify report content before it is displayed by handling the ReportDataSourceHelper.BeforeShowPreview event.


Mobile applications do not support the report preview mechanism, so the approach described in this topic cannot be implemented in the Mobile platform.

In this topic, it is assumed that you have an XAF application that uses the Reports V2 Module, and you have created one or more reports (see Reports V2 Module Overview).

To merge two reports right before they are displayed, implement the following helper class, which handles the ReportDataSourceHelper.BeforeShowPreview event. In this example, pages from the SecondReport will be appended to the pages of the FirstReport when the FirstReport is previewed.

using DevExpress.XtraReports.UI;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.ReportsV2;
// ...
public class MergeReportHelper {
    ReportDataSourceHelper helper;
    public MergeReportHelper(ModuleList modules) {
        ReportsModuleV2 module = ReportsModuleV2.FindReportsModule(modules);
        if (module != null) {
            module.ReportsDataSourceHelper.BeforeShowPreview +=
    private void ReportsDataSourceHelper_BeforeShowPreview(
        object sender, BeforeShowPreviewEventArgs e) {
        MergeReportsBeforeShow(e.Report, (ReportDataSourceHelper)sender);
    private void MergeReportsBeforeShow(
        XtraReport report, ReportDataSourceHelper reportsDataSourceHelper) {
        if (report is FirstReport) {
            report.AfterPrint += report_AfterPrint;
            helper = reportsDataSourceHelper;
    void report_AfterPrint(object sender, EventArgs e) {
        FirstReport firstReport = sender as FirstReport;
        SecondReport secondReport = new SecondReport();
        firstReport.PrintingSystem.ContinuousPageNumbering = true;

The ReportDataSourceHelper.SetupReport method call is required to display a report in XAF. Without it, the data source will not provide data.

Create an instance of the MergeReportHelper class after the application setup is complete. You can do it in the platform-agnostic module by handling the XafApplication.SetupComplete event in the overridden ModuleBase.Setup method.

public override void Setup(XafApplication application) {
    application.SetupComplete += delegate(object sender, EventArgs e) {
        new MergeReportHelper(((XafApplication)sender).Modules);