ActiveReports for .NET 3 Online Help Request technical support
Walkthrough: Master Detail Reports with XML Data
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Standard Edition Walkthroughs > Basic > Master Detail Reports Walkthroughs > Walkthrough: Master Detail Reports with XML Data

Glossary Item Box

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:

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

  1. Open a new project in Visual Studio.
  2. From the Project menu, select Add New Item.
  3. Select ActiveReports 3.0 File and rename the file rptMD.
  4. Click Open.

Connecting the report to a XML data source

To connect the report to a data source

  1. Click the gray report DataSource icon in the Detail section to open the report DataSource dialog.
  2. Select the "XML" tab.
  3. 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.)
  4. Click Open.
  5. In the Recordset Pattern field, type "//ITEM".
  6. Click OK to return to the report design surface.

Adding controls to the report to contain data

To add controls to the report

  1. Add two GroupHeader/Footer sections to your report by right-clicking on the report and selecting Insert > Group Header/Footer.
  2. 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
  3. 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
  4. 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:
    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
    • 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:
      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
    • 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

      Viewing the report

      To view the report

      1. Add the ActiveReports viewer control to a Windows Form.
      2. 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.

      See Also

      ©2009. All Rights Reserved.