ActiveReports 6 Online Help
Group On Unbound Fields
Show AllShow All
Hide AllHide All

ActiveReports allows you to set up grouping in unbound reports. When setting up grouping, the group header's DataField property is used to retrieve the grouping data from the database in the same manner as a textbox's DataField property. This walkthrough illustrates how to set up grouping in an unbound report.

This walkthrough is split into the following activities:

Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.

To complete the walkthrough, you must have access to the Northwind database.
A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB (on a 64-bit operating system, a copy is located in C:\Program Files (x86)\GrapeCity\ActiveReports 6\Data\NWIND.MDB).

When you have completed this walkthrough, you will have a report that looks similar to the following.

To add code to connect the report to a data source

  1. Double-click the gray area below the report. This creates an event-handling method for the report's ReportStart event.
  2. Add code to the handler to:
    • Set the data source connection string
    • Set the data source SQL query
    • Open the connection and retrieve the data with the data reader

The following examples show what the code for the method looks like in Visual Basic.NET and C#.

To write the code in Visual Basic.NET

To write the code in C#

To add controls to the report to contain data

  1. Back on the design surface of the report, right-click and select Insert, thenGroup Header/Footer to add group header and footer sections.
  2. Select the group header and make the following changes in the Properties Window.
    • Name: ghCategories
    • BackColor: Silver
    • CanShrink: True
    • DataField: CategoryID
    • GroupKeepTogether: All
    • KeepTogether: True
  3. Select the group footer, and in the Properties Window, change the Name property to gfCategories.
  4. Select the detail section, and in the Properties Window, change the CanShrink property to True.
  5. Add the following controls to the GroupHeader section (drag the bottom edge of the section down to display all of the controls):

    GroupHeader controls

  6. Add the following controls to the Detail section:

    Detail controls

  7. Add the following controls to the GroupFooter section:

    GroupFooter controls

  8. Right-click the PageHeader section and select Delete

To add fields using the DataInitialize event

Warning: Do not access the Fields collection outside the DataInitialize and FetchData events. Accessing the Fields collection outside of these events is not supported, and has unpredictable results.

To write the code in Visual Basic

To write the code in C#

To populate the fields using the FetchData event

To write the code in Visual Basic

To write the code in C#

Adding code to close the connection to the data source

To write the code in Visual Basic

To write the code in C#

See Also

How To

Concepts