To embed a subreport into a parent report, you add two reports to a Visual Studio project, and from the ActiveReports toolbox, drag the SubReport control onto one of the reports. You can then add code to create an instance of the child report, and to display it in the SubReport control.
Warning: Do not create a new instance of the subreport in the Format event. Doing so creates a new subreport each time the section Format code is run, which uses a lot of memory. |
To write the code in Visual Basic
The following example shows what the code for the method looks like.
Visual Basic.NET code. Paste JUST ABOVE the ReportStart event. |
Copy Code |
---|---|
Dim rpt As rptYourChildReportName |
Visual Basic.NET code. Paste INSIDE the ReportStart event. |
Copy Code |
---|---|
rpt = New rptYourChildReportName() |
To write the code in C#
The following example shows what the code for the method looks like.
C# code. Paste JUST ABOVE the ReportStart event. |
Copy Code |
---|---|
private rptYourChildReportName rpt; |
C# code. Paste INSIDE the ReportStart event. |
Copy Code |
---|---|
rpt = new rptYourChildReportName(); |
To write the code in Visual Basic
The following example shows what the code for the method looks like.
Visual Basic.NET code. Paste INSIDE the Format event. |
Copy Code |
---|---|
Me.SubReport1.Report = rpt |
To write the code in C#
The following example shows what the code for the method looks like.
C# code. Paste INSIDE the Format event. |
Copy Code |
---|---|
this.subReport1.Report = rpt; |