ActiveReports 6 Online Help Send comments on this topic.
Scripting
See Also
ActiveReports 6 > ActiveReports User Guide > Concepts > Scripting

Glossary Item Box

ActiveReports allows you to use VB.NET or C# script to port your custom logic to report layouts. This permits layouts saved to report XML (RPX) files to serve as stand-alone reports. By including scripting before you save the report layout as an RPX file, you can later load, run, and display the report directly to the viewer control without using the designer. In conjunction with RPX files, scripting allows you to update distributed reports without recompiling your project.

ActiveReports loads RPX files, including any scripting, in the InitializeComponent() method.

You can add C# or VB.NET code to the script editor at design time or by using the rpt.Script property at run time. The script is then saved to the RPX file along with layout information.

To access the script editor, click the script tab below the report design surface.

Since the RPX file can be read with any text editor, use the AddCode or AddNamedItem method to add secure information such as a connection string.

Note: The ActiveReports script editor supports IntelliSense that helps the writing of code by making the access to the language elements fast and easy.

Tips for Using Script

Difference in script and code-behind event handler method definition

Code-behind and the script editor require a different syntax for the event handler method definition. You should use the Private modifier in code-behind and the Public modifier in the script editor.

See the examples of the ReportStart event handler definition in Visual Basic and C# below:

ShowScript and code-behind examples in Visual Basic

The ReportStart event handler definition in the script editor:

Sub ActiveReport_ReportStart
End Sub 

The ReportStart event handler definition in code-behind:

Private Sub MyActiveReports_ReportStart(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.ReportStart
End Sub

ShowScript and code-behind examples in C#

The ReportStart event handler definition in the script editor:

public void ActiveReport_ReportStart()
{
} 

The ReportStart event handler definition in code-behind:

private void MyActiveReports_ReportStart(object sender, EventArgs e)
{
}

See Also