ActiveReports allows you to create Master Detail reports with data from an XML database.
This walkthrough illustrates how to create a Master Detail report using XML data and grouping.
This walkthrough is split up into the following activities:
- Adding an ActiveReport to a Visual Studio project
- Connecting the report to a XML data source
- Adding controls to the report to contain data
- Viewing the report
To complete the walkthrough, you must have access to the XML Customer database (customer.xml).
When you have completed this walkthrough, you will have a report that looks similar to the following.
Adding an ActiveReport to a Visual Studio project
To add an ActiveReport to your project
- Open a new project in Visual Studio.
- From the Project menu, select Add New Item.
- Select ActiveReports 3.0 File and rename the file rptMD.
- Click Open.
Connecting the report to a XML data source
To connect the report to a data source
- Click the gray report DataSource icon in the Detail section to open the report DataSource dialog.
- Select the "XML" tab.
- Click the ellipsis button beside File URL to browse for the access path to customer.xml. (Typically C:\Program Files\Data Dynamics\ActiveReports for .NET 3.0\Samples\CSharp\XMLSample\customer.xml or C:\Program Files\Data Dynamics\ActiveReports for .NET 3.0\Samples\VB\XMLSample\customer.xml.)
- Click Open.
- In the Recordset Pattern field, type "//ITEM".
- Click OK to return to the report design surface.
Adding controls to the report to contain data
To add controls to the report
- Add two GroupHeader/Footer sections to your report by right-clicking on the report and selecting Insert > Group Header/Footer.
- Make the following changes to the group header just below the page header:
- Change the Name property to ghCustomer
- Change the BackColor property to LightBlue
- Change the DataField property to ../../@id
- Add the following controls to ghCustomer:
Control DataField Name Text Location Font Style Label lblID ID 0, 0 Bold Label lblEmailAddress E-mail Address 2, 0 Bold Label lblName Name 4, 0 Bold TextBox ../../@id txtID ID 0, 0.25 TextBox ../../@email txtEmail E-mail 2, 0.25 TextBox ../../NAME txtName Name 4, 0.25 - Make the following changes to the group header just above the detail section:
- Change the Name property to ghOrders
- Change the BackColor property to LightCyan
- Change the DataField property to ../Number
- Add the following controls to ghOrders:
- Make the following changes to the Detail section:
- Change the BackColor property to WhiteSmoke
- Change the CanShrink property to True
- Add the controls to the Detail section:
- Add the following controls to GroupFooter2:
Control DataField Name Text Miscellaneous Location Label lblSubtotal Subtotal Font Style = Bold 4.5, 0 TextBox PRICE txtSubtotal Subtotal OutputFormat = Currency SummaryType = SubTotal
SummaryGroup = ghOrders
5.69, 0
Control | DataField | Name | Text | Location |
---|---|---|---|---|
Label | lblNumber | Order Number: | 0.38, 0 | |
TextBox | ../NUMBER | txtNumber | Number | 1.5, 0 |
TextBox | ../DATE | txtDate | Date | 4.5, 0 |
Label | lblISBN | ISBN | 0, 0.31 | |
Label | lblBookTitle | Book Title | 1.13, 0.31 | |
Label | lblPrice | Price | 5.69, 0.31 | |
Label | lblAuthor | Author | 3.5, 0.31 | |
Label | lblPublisher | Publisher | 4.56, 0.31 |
Control | DataField | Name | Text | Miscellaneous | Location |
---|---|---|---|---|---|
TextBox | @isbn | txtISBN | ISBN | 0, 0 | |
TextBox | TITLE | txtTitle | Title | 1.13, 0 | |
TextBox | AUTHOR | txtAuthor | Author | 3.5, 0 | |
TextBox | PUBLISHER | txtPublisher | Publisher | 4.56, 0 | |
TextBox | PRICE | txtPrice | Price | OutputFormat = Currency | 5.69, 0 |
Viewing the report
To view the report
- Add the ActiveReports viewer control to a Windows Form.
- Add the code needed to set the viewer document equal to the report document. See Using the ActiveReports Windows Form Viewer for help.
![]() |
You can quickly view your report at design time by clicking the Preview tab at the bottom of the designer. |