With ActiveReports, page numbering can be easily applied to groups in a report using the GroupHeader section.
This walkthrough illustrates the basics of setting up page numbering for groups in the GroupHeader section.
The walkthrough is split up into the following activities:- Adding an ActiveReport to a Visual Studio project
- Connecting the data source to a database
- Adding controls to the report to contain data
- Viewing the report
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 a Visual Studio project
To add an ActiveReport to your project
- From the Project menu, select Add New Item.
- Select ActiveReports 3.0 File and rename it rptNumberGH.
- Change the name of the report and click Open.
- The ActiveReports design surface is displayed.
Connecting the data source to a database
To connect the data source to a database
- Click on the gray report DataSource icon in the Detail section to open the report DataSource dialog.
- Select the "OLE DB" tab.
- Click on Build.
- Select "Microsoft Jet 4.0 OLE DB Provider" and click Next .
- Click the ellipsis button to browse for the access path to the NorthWind database. Click Open once you have selected the appropriate access path.
- Click OK to continue.
- In the Query field, type "Select * from customers order by country".
- Click OK to return to the report design surface.
Adding controls to contain data
To add controls to contain data
- Add a GroupHeader/Footer section to rptNumberGH by right-clicking the design surface of the report and selecting Insert > Group Header/Footer.
- Make the following changes to the group header:
- Change the name to ghCustomers
- Change the DataField property to Country
- Change the GroupKeepTogether property to FirstDetail
- Change the KeepTogether property to True
- Add the following controls to the GroupHeader section:
Control Name Text Miscellaneous Location ReportInfo reportInfo1 FormatString= Page{PageNumber} of {PageCount}
SummaryGroup= ghCustomers
SummaryRunning = Group
0, 0 Label lblCustomerID CustomerID 0, 0.25 Label lblCompanyName CompanyName 1.1875, 0.25 Label lblAddress Address 3.3125, 0.25 Label lblCountry Country 5.125, 0.25 - 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 CustomerID CustomerID 0, 0 CompanyName Company Name 1.1875, 0 Address Address 3.3125, 0 Country Country 5.114, 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. |