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.
To get started with this tutorial, open an existing reporting application or create a new application (the Add a Report to Your .NET Application section explains how to create a reporting application on different platforms).
Create a Detail Report
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.
Decrease the detail report's right margin, so that two reports will fit into the width of the master report.
Drop the required data fields from the Field List onto the report's Detail band and adjust the layout accordingly.
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
Add another report to the application (named masterReport) that will show the detail reports side-by-side.
Open your report in the Visual Studio Designer and press CTRL+ALT+X to run the Toolbox. Expand the DX.19.2: Report Controls category and drop two XRSubreport controls onto the report's Detail band.
Private Sub xrSubreport1_BeforePrint(ByVal sender As Object, ByVal e _
As PrintEventArgs) Handles XrSubreport1.BeforePrint
CType(sender, XRSubreport).ReportSource.FilterString = "[EmployeeID] = 1"
Private Sub xrSubreport2_BeforePrint(ByVal sender As Object, ByVal e _
As PrintEventArgs) Handles XrSubreport2.BeforePrint
CType(sender, XRSubreport).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.
Was this page helpful?
Thanks for your feedback! Any other suggestions? Tell us here.