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

Glossary Item Box

ActiveReports allows you to create Master Detail reports with grouping by using the GroupHeader and Detail sections to contain data from master files and detail files.

This walkthrough illustrates how to create a Master Detail report using grouping to organize the report.

This walkthrough is split up into the following activities:

To complete the walkthrough, you must have access to the Northwind database.
A copy is located at C:\Program Files\Data Dynamics\ActiveReports for .NET 3.0\Data\NWIND.MDB.

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 data source

To connect the report to a data source

  1. Click on the gray report DataSource icon in the Detail section to open the report DataSource dialog box.
  2. Select the "OLE DB" tab.
  3. Click the Build button.
  4. Select Microsoft Jet 4.0 OLE DB Provider and click Next.
  5. Click the ellipsis button to browse for the access path to the Northwind database. Click Open once you have selected the appropriate access path.
  6. Click OK to continue.
  7. In the Query field, type "Select * from orders, [order details], products where orders.OrderID = [order details].OrderID and products.productID = [order details].productID order by OrderDate".
  8. Click OK to return to the report design surface.

Adding controls to the report to contain data

To add controls to the report

  1. Change the BackColor property of the page header to Silver.
  2. Add labels to the page header with the following properties set:
    Name Text Font Style Location
    lblOrderDate Order Date Bold 0, 0
    lblShipName Ship Name Bold 1, 0
    lblShippedDate Shipped Date Bold 3, 0
    lblShipAddress Ship Address Bold 4, 0
    lblShipCountry Ship Country Bold 5.5, 0
  3. Add a GroupHeader/Footer section to rptMD by right-clicking the design surface of the report and selecting Insert > Group Header/Footer.
  4. Make the following changes to the group header:
    • Change the Name property to ghOrders
    • Change the BackColor property to LightGray
    • Change the DataField property to orders.OrderID
  5. In the Report Explorer, expand the Fields node, then the Bound node. Drag the following fields onto ghOrders and set the properties as indicated. 

    DataField Name Text OutputFormat Location
    OrderDate txtOrderDate1 Order Date MM/dd/yy 0, 0
    ShipName txtShipName1 Ship Name 1, 0
    ShippedDate txtShippedDate1 Shipped Date  MM/dd/yy 3, 0
    ShipAddress txtShipAddress1 Ship Address 4, 0
    ShipCountry txtShipCountry1 Ship Country 5.5, 0 
  6. Add another GroupHeader/Footer section to your report.
  7. Change the BackColor property of the group header to LightSteelBlue.
  8. Add labels to the group header with the following properties set:
    Name Text Font Style Location
    lblOrderID Order ID Bold 0, 0
    lblProductName Product Name Bold 1, 0
    lblProductID Product ID Bold 3, 0
    lblUnitPrice Unit Price Bold 4, 0
    lblQuantity Quantity Bold 5.5, 0
  9. Make the following changes to the detail section:
    • Change the BackColor property to AliceBlue
    • Change the CanShrink property to True
  10. In the Report Explorer, expand the Fields node, then the Bound node. Drag the following fields onto the detail section and set the properties as indicated.  

    DataField Name Text Miscellaneous Location
    orders.OrderID txtOrderID1 Order ID 0, 0
    ProductName txtProductName1 Product Name 1, 0
    products.ProductID txtProductID1 Product ID 3, 0
    products.UnitPrice txtUnitPrice1 Unit Price OutputFormat = Currency 4, 0
    Quantity txtQuantity1 Quantity 5.5, 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.