Reports for WinForms | ComponentOne
C1.C1Report.4 Assembly / C1.C1Report Namespace / C1Report Class / AddScriptObject Method / AddScriptObject(String,Object) Method
Name of the new object (case-insensitive).
Value of the new object.
Example

In This Topic
    AddScriptObject(String,Object) Method
    In This Topic
    Adds an object to the report's script context.
    Syntax
    'Declaration
     
    Public Overloads Sub AddScriptObject( _
       ByVal name As String, _
       ByVal value As Object _
    ) 
    public void AddScriptObject( 
       string name,
       object value
    )

    Parameters

    name
    Name of the new object (case-insensitive).
    value
    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.

    Example

    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.

    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();
    }
    See Also