ActiveReports 6 Online Help
Basic XML-Based Reports (RPX)
Show AllShow All
Hide AllHide All

ActiveReports 6 allows you to create reports with embedded script and save them to the XML-based RPX file format. By embedding script in reports saved as RPX files, you can later load, run, and display reports directly in the viewer control without rebuilding the application. This walkthrough illustrates how to create a simple report, using the XML-based report template.

This walkthrough is split into the following activities:

Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.

To complete the walkthrough, you must have access to the Northwind database. A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB (on a 64-bit Windows operating system, a copy is located in C:\Program Files (x86)\GrapeCity\ActiveReports 6\Data\NWIND.MDB).

When you have finished this walkthrough, you will have a report that looks similar to the following.

To add controls to the report

  1. Add an ActiveReports 6 (xml-based) File to a Visual Basic project and name it rptScript.
  2. In the Solution Explorer click the rptScript.rpx item and set the Build Action property to Embedded Resource.
  3. Add the following controls to the Detail section:

    Detail section fields

  4. Click just below the fields to select the Detail section.
  5. In the Properties Window, set the CanShrink property to True to eliminate white space in the rendered report.

To add scripting to the report to supply data for the controls

  1. Click the Script tab located at the bottom edge of the report designer to access the scripting editor.

  2. Add the scripting code.

The following example shows what the scripting code looks like.

Warning: Do not access the Fields collection outside the DataInitialize and FetchData events. Accessing the Fields collection outside of these events is not supported, and has unpredictable results.

To write the script in Visual Basic.NET

To write the script in C#

To add scripting to alternate colors in the detail section

  1. Click the Script tab located at the bottom edge of the report designer to access the scripting editor.

  2. Add the scripting code.

The following example shows what the scripting code looks like.

To write the script in Visual Basic.NET

To write the script in C#

To view the report

You can quickly view your report at design time by clicking the Preview tab at the bottom of the designer.

  1. Drag the ActiveReports viewer control from the Visual Studio toolbox onto the Windows Form and set its Dock property to Fill.
  2. Double-click the title bar of the Windows Form containing the viewer to create a Form_Load event and add the code needed to load the RPX into a generic ActiveReport and display it in the viewer.

The following example shows what the code for the method looks like.

 To write the script in Visual Basic.NET

To write the script in C#

See Also

Getting Started

Concepts