Create a Side-by-Side Report

This tutorial describes the steps required to create a report that shows two subreports side-by-side, at design time within Visual Studio. Each subreport displays information about a selected employee, providing a convenient way to put employee resumes together. You can use a similar approach to show two completely different reports (which use different data sources) within a single report document.

HowTo - SideBySideReport_2

Tip

To get started with this tutorial, open an existing reporting application or create a new one from scratch. See Adding a Report to Your .NET Application to learn how to create a reporting application on different platforms.

Perform the actions below to create a side-by-side report.

Create a Detail Report

  1. To create a detail report in this tutorial, start with a report (named detailReport1) that is bound to the "Employees" table of the sample Northwind database (the nwind.mdb file included in the XtraReports installation). To learn more about binding a report to a data source, see Provide Data to Reports.
  2. Decrease the detail report's right margin, so that two reports will fit into the width of the master report.

    HowTo - SideBySideReport_0

  3. Drop the required data fields from the Field List onto the report's Detail band and adjust the layout accordingly.

    HowTo - SideBySideReport_1

    You can use the mail merge feature to make a control show both static and dynamic content, or to bind a control to several data fields simultaneously.

Create a Side-by-Side Report

  1. Add another report to the application (named masterReport) that will show the detail reports side-by-side.
  2. Open your report in the Visual Studio Designer and press CTRL+ALT+X to run the Toolbox. Expand the DX.18.1: Report Controls category and drop two XRSubreport controls onto the report's Detail band.

    HowTo - SideBySideReport_1a

  3. For both subreports, set the SubreportBase.ReportSource property to detailReport1 and set the Size.Width to 300.

    HowTo - SideBySideReport_1b

  4. To apply the changes, select BUILD | Rebuild Solution in the main menu of the project.

    Shared_RebuildSolution

  5. To select an employee for each subreport, handle the subreports' BeforePrint event in the following way.

    using System.Drawing.Printing;
    using DevExpress.XtraReports.UI;
    // ...
    
    private void xrSubreport1_BeforePrint(object sender, PrintEventArgs e) {
        ((XRSubreport)sender).ReportSource.FilterString = "[EmployeeID] = 1";
    }
    
    private void xrSubreport2_BeforePrint(object sender, PrintEventArgs e) {
        ((XRSubreport)sender).ReportSource.FilterString = "[EmployeeID] = 2";
    }
    

Your report is now ready to be generated. In Visual Studio, you can view the report by switching to the Preview tab.