ActiveReports 6 Online Help
Script Property
Example 

Sets or returns the script code for a report's events.  Either this property or the script editor may be used to add script to a report.
Syntax
'Declaration
 
Public Property Script As String
public string Script {get; set;}

Property Value

The current script code. The default value is an empty string.
Remarks

The Script property can be used to make modifications to the report outside the code written in the report's events. The script events run immediately after their matching ActiveReports code-behind events and take precedence over the code inside the project.

If reports with scripts are saved to XML, the scripts (unlike code-behind) are incorporated into the XML file. Changes can be made to the XML file scripts and then loaded back into a report project to show the changes. This allows reports to be modified without requiring the project to be recompiled.

When referencing the report in the script, use rpt instead of the report's name or "Me" or "this".

In order to reference a member of the report class using the "rpt" named object, the member has to be a public member. You can use a control's modifier property to change the generated code for a control from private to public.

If you plan to run the report from a stand-alone RPX file without the compiled code-behind class, your scripting code would have to reference the report class controls using the Controls collection instead of by name.

Scripts are compiled at run time using the language specified in the ScriptLanguage property.

Example
This snippet assumes that you have html in the RichTextBox, and that the Modifiers property of the RichTextBox is set to Public.
Private void btnScript_Click(object sender, System.EventArgs e)
{
    string sScript = string.Empty;
    rptDataDynamics rpt = New rptDataDynamics();

    sScript += "public void ReportHeader_Format()";
    sScript += "{";
    sScript += "rpt.RichTextBox1.Html = rpt.RichTextBox1.Text;";
    sScript += "}";

    rpt.Script = rpt.Script + "\n" + sScript;
    rpt.Run();
    arv.Document = rpt.Document;
}
Private Sub btnScript_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScript.Click
    Dim sScript As String = String.Empty
    Dim rpt As New rptDD

    sScript = "public void ReportHeader_Format()"
    sScript = sScript + "{"
    sScript = sScript + "rpt.RichTextBox1.Html = rpt.RichTextBox1.Text;"
    sScript = sScript + "}"

    rpt.Script = sScript
    rpt.Run()
    Viewer1.Document = rpt.Document
End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ActiveReport Class
ActiveReport Members
ScriptLanguage Property

Send Feedback