ActiveReports 17 .NET Edition
Report Authors: Designer Components / Report Controls / Section Report / SubReport
In This Topic
    In This Topic

    In section reports, you can use the SubReport control to embed a report into another report. Once you place the SubReport control on a report, use code to create an instance of the report you want to load in it, and attach the report object to the SubReport.

    You can also pass parameters to the subreport from the main report so that data related to the main report displays in each instance of the subreport.

    Note: You cannot use a Page/RDL report as the target of a SubReport in a Section report.

    Remove page-dependent features from reports to be used as subreports

    Subreports are disconnected from any concept of a printed page because they render inside the main report. For this reason, page-dependent features are not supported for use in subreports. Keep any such logic in the main report. Page-related concepts that are not supported in subreports include:

    Coding best practices

    Use the ReportStart event of the main report to create an instance of the report for your SubReport control, and then dispose of it in the ReportEnd event. This way, you are creating only one subreport instance when you run the main report.

    In the Format event of the containing section, use the Report property of the SubReport control to attach a report object to the SubReport control.

    Caution: It is not a recommended practice to initialize the subreport in the Format event. Doing so creates a new instance of the subreport each time the section processes. This consumes a lot of memory and processing time, especially in a report that processes a large amount of data.

    Important Properties

    Clicking the SubReport control reveals its properties in the Properties window.

    Property Description
    CanGrow Determines whether ActiveReports increases the height of the control based on its content.
    CanShrink Determines whether ActiveReports decreases the height of the control based on its value.
    CloseBorder By default, the bottom border of the control does not render until the end of the subreport. Set this property to True to have it render at the bottom of each page. (Only available in code)
    Report Attaches a report object to the control. (Only available in code)

    SubReport Dialog Properties

    With the control selected on the report, in the Commands section at the bottom of the Properties window, you can click the Property dialog command to open the dialog.

    Name: Enter a name for the SubReport that is unique within the report. This name is displayed in the Document Outline and in XML exports. You can only use underscore (_) as a special character in the Name field. Other special characters such as period (.), space ( ), forward slash (/), back slash (\), exclamation (!), and hyphen (-) are not supported.

    Tag: Enter a string that you want to persist with the control. If you access this property in code, it is an object, but in the Properties window or Property dialog, it is a string.

    Visible: Clear this check box to hide the control.

    ReportName: Enter the name of the report.

    SubReport Height

    Can increase to accommodate contents: Clear this check box to set CanGrow to False.

    Can decrease to accommodate contents: Clear this check box to set CanShrink to False.


    Using SubReport Control in Reports

    To use the SubReport control in your report, you must create two reports - one parent and one child report. Then, after dragging the SubReport control onto the parent report, you need to add code to create an instance of the child report in the parent report, and another code to display the child report in the SubReport control on a parent report.

    For details on working with SubReport control in section reports, see Work with Subreports.