Adds an object to the report's script context.
Namespace:
C1.C1ReportAssembly: C1.C1Report.2 (in C1.C1Report.2.dll)
Syntax
C# |
---|
public void AddScriptObject( string name, Object value ) |
Visual Basic |
---|
Public Sub AddScriptObject ( _ name As String, _ value As Object _ ) |
Parameters
- name
- Type: System..::..String
Name of the new object (case-insensitive).
- value
- Type: System..::..Object
Value of the new object.
Remarks
This method allows you to add custom objects to the context of the C1Report script interpreter.
The script interpreter context is cleared whenever a report starts rendering, so this method should always be called from the StartReport event handler.
Examples
The code below uses the StartReport event to add a variable called "mainForm" to the script context. It then attaches some script to the report's OnOpen event to show the caption of the form when the report starts rendering.
Copy CodeC#
private void _c1r_StartReport(object sender, System.EventArgs e) { _c1r.AddScriptObject("mainForm", this); } private void button1_Click(object sender, System.EventArgs e) { _c1r.OnOpen = "msgbox(mainForm.Text)"; _c1r.Render(); } |