Walkthrough: Data Bound Reports
In ActiveReports, the simplest reporting style is a tabular listing of fields from a record source.
This walkthrough illustrates the basics of setting up bound reports by introducing the ideas of using the DataSource icon and connecting textbox controls to the data source through the DataField property.
The walkthrough is split up into the following activities:
- Creating a new Visual Studio project
- Adding an ActiveReport to the Visual Studio project
- Connecting the data source to a database
- Adding controls to contain the data
- Viewing the report
To complete the walkthrough, you must have access to the NorthWind database (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.
-
Click on File > New > Project.
- Select the project type and click on Windows Application.
- Change the name of your project and click OK.
Adding an ActiveReport to the Visual Studio project
To add an ActiveReport to your project
- Click on Project > Add New Item.
- Select ActiveReports file and rename the file rptBound.
- Click Open.
Connecting the data source to a database
To connect the data source to a database
- Click on the yellow report DataSource icon in the Detail section. This brings up the report DataSource dialog box.
- Click on Build...
- Select "Microsoft Jet 4.0 OLE DB Provider" and click Next >>.
- Click on the ellipsis to browse for the access path to Nwind.mdb. Click Open once you have selected the appropriate access path.
- Click OK to continue.
- In the Query field, type "Select * from products".
- Click OK to return to the report design surface.
Adding controls to contain data
To add controls to contain data
- Drag the following fields from the Report Explorer window: ProductName, QuantityPerUnit and UnitsInStock.
- Drop these textboxes into the Detail section and arrange them horizontally in the above order.
- Resize the Detail section to remove extra white space.
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 WinForm Viewer for help.
Note: You need to include references to the RtfExport and TextExport dlls in order to enable the viewer's copy button.
Samples | Walkthroughs
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.