Parameters can be used with charts to connect the information shown in the chart to that shown in the report. By setting a parameter for the field that links the report to the chart, the report can pass the information to the chart through the parameters.
This walkthrough illustrates how to set up a chart using parameters to link the report to the chart.
This walkthrough is split up into the following activities:
- Creating a new Visual Studio project
- Adding an ActiveReport to a Visual Studio project
- Connecting the report to a data source
- Adding controls to display the data
- Setting a data source for the chart using parameters
- Setting the chart's properties
- 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.
Creating a new Visual Studio project
To create a new Visual Studio project
- Open Visual Studio.
-
From the File menu, select New > Project.
- Select the project type and click on Windows Application.
- Change the name of your project and click OK.
Adding an ActiveReport to a Visual Studio project
To add an ActiveReport to a Visual Studio project
- Open a new project in Visual Studio.
- From the Project menu, select Add New Item.
- Select ActiveReports 3.0 File and rename the file rptChartParams.
- Click Open.
Connecting the report to a data source
To connect the report to a data source
- 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 Products ORDER BY CategoryID, ProductName".
- Click OK to return to the report design surface.
Adding controls to display the data
To add controls to the reports
- Right-click on the report and delete the PageHeader/Footer section pair.
- Right-click on the report and insert a GroupHeader/Footer section pair.
- Make the following changes to the GroupHeader section:
- Change the Name property to ghCategoryID
- Change the DataField property to CategoryID
- Change the GroupKeepTogether property to All
- Change the Height property to 5.65 in
- Change the Height property of the Detail section to 0.23 in.
- Change the Height property of the GroupFooter section to 0 in.
- Add the following controls to rptChartParams, setting the properties as indicated:
Control DataField Name Text Section Location Label lblCategoryID Category ID Number: ghCategoryID 1.78, 0 TextBox CategoryID txtCategoryID CategoryID ghCategoryID 3.72, 0 ChartControl chartControl1 ghCategoryID 0.063, 0.313 Label lblProductName Product Name ghCategoryID 0.23, 5.43 Label lblUnitsInStock Units In Stock ghCategoryID 5, 5.43 TextBox ProductName txtProductName ProductName Detail 0.23, 0 TextBox UnitsInStock txtUnitsInStock UnitsInStock Detail 5, 0.23
Setting a data source for the chart
To connect the data source to a database
- With the chart control highlighted, click the Data Source verb below the Properties Window to open the Chart DataSource dialog.
- Click Build.
- Select "Microsoft Jet 4.0 OLE DB Provider" and click Next.
- Click the ellipsis button to browse to the NorthWind database. Click Open once you have selected the file.
- Click OK to continue.
- In theQuery field, type "SELECT * FROM Products WHERE CategoryID = <%CategoryID||1%> ORDER BY ProductName."
- Click OK to return to the report design surface.
![]() |
When using parameters, the chart draws at run time but not at design time if you do not provide a default value. |
![]() |
If you don't set the ORDER in both SQL statements (i.e. that of the report and that of the chart), the chart data will not be ordered. |
Setting the chart's properties
To set the chart's properties
- With the chart control highlighted, click the ChartAreas (Collection) property in the Properties Window, then click the ellipsis button to open the ChartArea Collection Editor.
- In the defaultArea Properties, click the Axes (Collection) property, then click the ellipsis button to open the AxisBase Collection Editor.
- Click the AxisX member, and set its LabelFont > Angle property to 90 so the ProductName labels will not overlap.
- Click the AxisY member, and set its Title property to "Units in Stock".
- Still in the AxisY member, expand the MajorTick property treeview node and set the following properties:
- Change the GridLine > Style property to Dot
- Change the GridLine > Color property to Silver
- Change the GridLine > Weight property to 1
- Click OK to return to the ChartArea Collection Editor.
- Click OK to return to the report design surface.
- With the chart control highlighted, click the Series (Collection) property in the Properties Window, then click the ellipsis button to open the Series Collection Editor.
- Click Series1 to select it.
- Change the ValueMembersY property to UnitsInStock.
- Change the ValueMembersX property to ProductName.
- Remove Series2 and Series3.
- Click OK to return to the report design surface.
- With the chart control highlighted, click the Titles (Collection) property in the Properties Window, then click the ellipsis button to open the Title Collection Editor.
- In the header properties, change the Text property to "Products In Stock."
- Remove the footer title and click OK to return to the report design surface.
- With the chart control highlighted, click the Legends (Collection) property in the Properties Window, then click the ellipsis button to open the Legend Collection Editor.
- Change the Visible property of the defaultLegend to False.
- Click OK to return to the report design surface.
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. |

