ActiveReports 9 > ActiveReports User Guide > Concepts > Section Report Concepts > Scripting in Section Reports |
To access the script editor, click the script tab below the report design surface. The script tab contains two drop-downs (Object and Event).
Add script to the events in the same way that you add code to events in the code view of the report. When you select an event, the script editor generates a method stub for the event.
Using the ScriptLanguage property of the report, you can set the script language that you want to use.
You can also add scripts at runtime using the Script property.
Caution: 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 basic approach of using the "this/Me" and "rpt" keywords is as follows - use "this/Me" to access the properties and controls added to the sections of the report, whereas use "rpt" within the instance of the ActiveReports class only to access its public properties, public events and public methods. |
Note: A declared variable is not static by default. Use the static keyword to declare static variables. |
Code-behind and the script tab require a different syntax for the event handler method definition. Use the Private modifier in code-behind and the Public modifier in the script editor.
See the following examples of the ReportStart event handler definition in Visual Basic and C#:
Script and code-behind examples in Visual Basic
The ReportStart event handler definition in the script editor:
Visual Basic.NET |
Copy Code
|
---|---|
Sub ActiveReport_ReportStart End Sub |
The ReportStart event handler definition in code-behind:
Visual Basic.NET |
Copy Code
|
---|---|
Private Sub SectionReport1_ReportStart(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.ReportStart End Sub |
Script and code-behind examples in C#
The ReportStart event handler definition in the script editor:
CS |
Copy Code
|
---|---|
public void ActiveReport_ReportStart() { } |
The ReportStart event handler definition in code-behind:
CS |
Copy Code
|
---|---|
private void SectionReport1_ReportStart(object sender, EventArgs e) { } |