ActiveReports for .NET 3 Online Help Request technical support
Walkthrough: Creating and Modifying Report Layouts at Run Time
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Standard Edition Walkthroughs > Advanced > Run-Time Reporting Walkthroughs > Walkthrough: Creating and Modifying Report Layouts at Run Time

Glossary Item Box

ActiveReports objects and controls are completely accessible at run time. The properties of any of the report sections or controls can be modified to produce a dynamic view of the report. The format event allows the properties of report sections and controls to be modified including height, visibility, and other visual properties. The format event is the only event in which the printable area of a section can be modified. Once this event is completed, any changes to the section's height will not be reflected in the report output.

Controls may be added dynamically in the ReportStart event but should not be added dynamically after the ReportStart event is raised as problems may result.
This walkthrough illustrates how to create a report layout at run time based on user input.

This walkthrough is split up 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 an output that looks similar to the following.

Adding an ActiveReport to your project

To add an ActiveReport to your project

  1. From the Project menu, select Add New Item.
  2. Select ActiveReports 3.0 File and rename the file rptFieldsRT.
  3. Click Open.

Connecting the report to a data source

To connect the report to a data source

  1. Click on the gray report DataSource icon in the Detail section to open the report DataSource dialog.
  2. Click on Build.
  3. Select "Microsoft Jet 4.0 OLE DB Provider" and click Next.
  4. Click the ellipsis button to browse for the access path to the Northwind database. Click Open once you have selected the appropriate access path.
  5. Click OK to continue.
  6. In the Query field, type "Select * from products".
  7. Click OK to return to the report design surface.

Adding controls to the Windows Form to contain data

To add controls to the form

Generating a dataset for the Windows Form

To generate the dataset

  1. From the Project menu, select Add New Item.
  2. Select DataSet, rename the file to NWINDDataSet.xsd and click the Add button.
  3. Open the Server Explorer by clicking its link in the DataSet designer.
  4. In the Server Explorer, expand the node for your local copy of the Northwind database and drag the Products table onto the DataSet designer. If you do not see a copy of the Northwind database, click the "Connect to Database" icon and follow the prompts.
  5. In the design view of your Windows form, expand the Data section of the Visual Studio Toolbox and double-click DataSet to open the Add Dataset dialog.
  6. Under Typed dataset, select <project name>.NWINDDataSet and click OK to make the dataset available to your Windows form.

Adding code to create the report layout

To add code to create the report layout

Adding code to the Windows Form

To add code to the form

Adding code to the Detail_Format event

To write the code in Visual Basic or C#

Adding code to the ReportStart event

To write the code in Visual Basic or C#

Adding code for btnGenRep's Click event

To write the code in Visual Basic or C#

Adding code to the clbFields_SelectedIndexChanged event

To write the code in Visual Basic

To write the code in C#

Adding code to the Windows Form_Load event

To write the code for the viewer in Visual Basic or C#

Viewing the report

To view the report

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.