Create SubReport in Code

TECH TIP: Creating a SubReport in Code

A subreport is comprised of two objects:

SubReport Control

The subreport control is added to a band of the ‘parent’ report. It has properties such as ShiftRelativeTo, PrintBehavior, etc. In the Report Designer, the subreport is drawn as a rectangle.

ChildReport

The child report is a descendant of CustomReport and has most of the same properties as a standard Report. The child report has a separate layout workspace in the report designer that is accessible by selecting the tabs at the bottom of the designer.

When dynamically creating a subreport in code you need to create the subreport and the underlying child report. The subreport.Report property can then be used to access the child report.

This is demonstrated in the following example: