The SubReports sample demonstrates how SubReport control can be used to generate nested and hierarchical reports.
Sample Location
Visual Basic.NET
<User Folder>\Documents\GrapeCity Samples\ActiveReports 12\Section Reports\Layout\SubReport\VB.NET
C#
<User Folder>\Documents\GrapeCity Samples\ActiveReports 12\Section Reports\Layout\SubReport\C#
Run-Time Features
When you run this sample, the blank Viewer form appears, with the drop-down list of the sample reports on the top of the form. Select the report from the drop-down list to have it displayed in the Viewer control. You can select from the following options.
Note: To run this sample, you must have access to the Nwind.mdb. A copy is located at [User Documents folder]\GrapeCity Samples\ActiveReports 12\Data\NWIND.mdb. If you are unable to access the data files in the sample, create the Data folder and place all the data files to this folder, or change the reference path to the data files within the folder according to your environment.
Project Details
ViewerForm
The ViewerForm uses the ActiveReports Viewer control in the bottom section of the form, and a panel docked to the top with the drop-down list. The Viewer displays a report once it is selected from the list.
rptBookmarkMain
This report is displayed when you select the Bookmark in SubReport option in the drop-down list of the ViewerForm.
This report uses bookmarks that you can see in the Document map of the Viewer sidebar, which is displayed if you click the Toggle sidebar button in the Viewer's toolbar. See Linking in Reports and Add Bookmarks for details on using bookmarks in ActiveReports.
The report uses the PageHeader section to display the name of the report, the Detail section to display data and the PageFooter section to display the report information. The Detail section contains the Subreport control that displays data from rptBookmarkSub.
The report is bound to Nwind.mdb at run time.
rptBookmarkSub
This report contains the Product List information for the Subreport control in rptBookmarkMain.
This report also contains bookmarks, which are setup in code in the Detail Format event.
rptDSRelationChildMain
This report displays the Product Name information and is the subreport for rptDSRelationParent.
The report uses the GroupHeader section to group data by Product Name and to display the label for the data in the Detail section, and the Detail section to display data. The Detail section contains the Subreport control that displays data from rptDSRelationChildSub.
The report is bound to the data row collection.
rptDSRelationChildSub
This report displays the Order Details information and is the subreport for rptDSRelationChildMain.
rptDSRelationParent
This report is displayed when you select the SubReport using the data set that contains relationship option in the drop-down list of the ViewerForm. This report demostrates how to bind a subreport to a dataset with a relation, defined in the DataSet.Relations property in code, and how to work with nested data relations.
The report uses the PageHeader section to display the name of the report, the groupHeader1 section to provide labels for the report data, the ghCategories to group data by Category Name, the Detail section to display data, and the PageFooter section to display the report information. The Detail section contains the Subreport control that displays the Product Name data from rptDSRelationChildMain.
The report is bound to the data row collection.
rptHierarchicalMain
This report is displayed when you select the Hierarchical SubReport option in the drop-down list of the ViewerForm.
The report uses the Detail section to display data and the PageFooter section to display the report information. The Detail section contains the Subreport control that displays data from rptHierarchicalSub.
The report is bound to Nwind.mdb at run time.
rptHierarchicalSub
This report displays the Order information and is the subreport for rptHierarchicalMain.
rptMasterMain
This report is displayed when you select the Master-detail report containing a SubReport option in the drop-down list of the ViewerForm. This report displays orders with the general information, the order details in this report are taken from rptMasterSub.
The report uses the PageHeader section to display the name of the report, the Detail section to display data and the PageFooter section to display the report information. The Detail section contains the bound Textbox controls that display information for each order and the Subreport control that displays order details from rptMasterSub.
The report is bound to Nwind.mdb at run time.
rptMasterSub
This report displays the Order Details information and is the subreport for rptMasterMain.
rptNestedChildMain
This report displays the Order Details information and is the subreport for rptNestedParent.
The report uses the groupHeader1 section to group the data by Orders ID, the groupHeader2 section to display static labels for the data in the Detail section, and the Detail section to display data. The groupHeader2 section contains the Subreport control that displays data from rptNestedChildSub.
The report is bound to Nwind.mdb at run time.
rptNestedChildSub
This report displays the Contact information and is the subreport for rptNestedChildMain.
The report is bound to Nwind.mdb at run time.
rptNestedParent
This report is displayed when you select the Nested SubReport option in the drop-down list of the ViewerForm. This report demonstrates how to set up embedded subreports to display main, child, and grandchild levels in a report.
The report uses the PageHeader section to display the name of the report, the groupHeader section to group the report data by Employee ID and to display static labels for the data in the Detail section, the Detail section that displays data on each employee, and the PageFooter section to display the report information. The Detail section contains the Subreport control that displays data from rptNestedChildMain.
The report is bound to Nwind.mdb at run time.
rptParamMain
This report is displayed when you select the Use a parameter in the SubReport option in the drop-down list of the ViewerForm. This report demonstrates how to set up a parameter in the subreport. See Parameters for more details.
The report uses the PageHeader section to display the name of the report, the groupHeader section to group data by Country and to display static labels for the report data, the Detail section to display Contact information, and the PageFooter section to display the report information. The Detail section contains the Subreport control that displays data from rptParamSub.
The report is bound to Nwind.mdb at run time.
rptParamSub
This report displays the Product Name information and is the subreport for rptParamMain.
The report is bound to Nwind.mdb at run time.
The parameter is added to the sql query at run time. Right-click rptParamSub in the Solution Explorer and select View Code to see the code implementation for the subreport parameter.
See Add Parameters in a Section Report for more details.
rptSimpleMain
This report is displayed when you select the Simple SubReport option in the drop-down list of the ViewerForm.
The report uses the PageHeader section to display the name of the report, the Detail section and the PageFooter section to display the report information. The Detail section contains the bound Textbox control to display the Category Name information and the Subreport control to display data from rptSimpleSub.
The report is bound to Nwind.mdb at run time.
rptSimpleSub
This report displays the Product Name information and is the subreport for rptSimpleMain.
The Detail section contains the Barcode control.
rptUnboundDSMain
This report is displayed when you select the To view the DataSet with multiple tables using SubReports option in the drop-down list of the ViewerForm.
The report uses the PageHeader section to display the name of the report, the Detail section and the PageFooter section to display the report information. The Detail section contains the bound Textbox controls to display Customer ID and Company Name, and the Subreport control to display data from rptUnboundDSSub.
The report is bound to the DataSet with multiple tables at run time. Right-click rptUnboundDSMain in the Solution Explorer and select View Code to see the code implementation for the dataset connection.
rptUnboundDSSub
This report displays the Order Detail information and is the subreport for rptUnboundDSMain.
The report uses the GroupHeader section to display static labels for Order List details in the Detail section.