ActiveReports for .NET 3 Online Help Request technical support
Walkthrough: Unbound Reports
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Standard Edition Walkthroughs > Advanced > Unbound Reports > Walkthrough: Unbound Reports

Glossary Item Box

ActiveReports allows you to bind reports to any type of data source, including arrays. You can create a report without setting its data source then load the data into the control at run time.

This walkthrough illustrates the fundamentals of using the DataInitialize and FetchData events to set up an unbound report.

This walkthrough is split 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 completed 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

  1. Open a new project in Visual Studio.
  2. From the Project menu, select Add New Item.
  3. Select ActiveReports 3.0 File and rename the file rptUnbound.
  4. Click Open.

Adding code to connect the report to a data source

To write the code in Visual Basic or C#

Adding controls to the report to contain data

To add controls to the report

Add the following controls from the ActiveReports 3.0 toolbox to the Detail section of rptUnbound:

Control DataField Name Text Location
TextBox ProductName txtProductName Product Name 0.0625, 0.375
TextBox UnitsInStock txtUnitsInStock Units In Stock 4.75, 0.375
TextBox Description txtDescription Description 1.8125, 0.6875
TextBox CategoryName txtCategoryName Category Name 3.125, 0.375
Label NA lblCategoryDescription Category Description 0.0625, 0.6875
Label NA lblUnitsInStock Units In Stock 4.75, 0.0625
Label NA lblCategoryName Category Name 3.125, 0.0625
Label NA lblProductName Product Name 3.125, 0.375
Line NA line1 NA X1 = 0

X2 = 6.5

Y1 = 1.0625

Y2 = 1.0625

Additionally, you can set the BackColor property of the label controls to an opaque color to make your report easier to read.

Using the DataInitialize event to add fields

To write the code in Visual Basic

To write the code in C#

Using the FetchData event to populate the report fields

To write the code in Visual Basic

To write the code in C#

The DataInitialize and FetchData events are the only events in which the Fields collection should ever be referenced.

Using the ReportEnd event to close the data connection

To write the code in Visual Basic

To write the code in C#

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.