ActiveReports for .NET 3 Online Help Request technical support
Walkthrough: Group on Simple Fields
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Standard Edition Walkthroughs > Basic > Grouping Data Walkthroughs > Walkthrough: Group on Simple Fields

Glossary Item Box

In ActiveReports, reports can be grouped by using a group header with the DataField property set to the database field on which it is being grouped. ActiveReports allows up to 32 nested groups in a single report. When using grouping, make sure the returned dataset is ordered by the fields on which it is being grouped.

This walkthrough illustrates the basics of setting up grouping on simple fields in a report.

The 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 finished this walkthrough, you will have a report that looks similar to the following.

Adding an ActiveReport to your project

To add an ActiveReport to your project

  1. From the Project menu, select Add New Item.
  2. Click ActiveReports 3.0 File.
  3. Change the name of the report to rptSimpleGroup and click Open.  

Connecting the data source to a database

To connect the data source to a database

  1. Click on the gray report DataSource icon in the Detail section to open the report DataSource dialog.
  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 customers ORDER BY country".
  8. Click OK to return to the report design surface.

Adding controls to contain data

To add controls to the report

  1. Add a GroupHeader/Footer section to your report by right-clicking the design surface of the report and selecting Insert > Group Header/Footer.
  2. Make the following changes to the group header:
    • Change the Name property to ghOrderGroup
    • Change the DataField property to Country
  3. Add labels with the following properties to ghOrderGroup:

    Name Text Location
    lblCustomerID Customer ID 0, 0.31
    lblCompanyName Company Name 1.06, 0.31
    lblContactName Contact Name 3.25, 0.31
    lblContactTitle Contact Title 5, 0.31
  4. Add a field with the following properties set to ghOrderGroup:

    Miscellaneous DataField Name Text Location
    Font size = 14; ForeColor = DarkRed; Bold  Country txtCountry Country 0.313, 0.063
  5. In the Report Explorer, expand the Fields node, then the Bound node. Drag the following fields onto the detail section and set the following properties of each textbox as indicated.

    Field Text Location Size
    CustomerID Customer ID 0, 0 1, 0.2
    CompanyName Company Name 1.06, 0 2.06, 0.2
    ContactName Contact Name 3.25, 0 1.63, 0.2
    ContactTitle Contact Title 5, 0 1.5, 0.2
  6. Set the CanShrink property of the detail section to True.

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.