ActiveReports 18 .NET Edition
MESCIUS.ActiveReports Assembly / GrapeCity.ActiveReports Namespace / SectionReport Class / AddCode Method
Script code written in the specified report scripting language.
Example

In This Topic
    AddCode Method
    In This Topic
    Adds additional valid script code to the report's scripting context.  Using AddCode allows complete functions to be added to a report's script at run time.  The added functions can be called from the report events in script.
    Syntax
    'Declaration
     
    Public Sub AddCode( _
       ByVal script As String _
    ) 
    public void AddCode( 
       string script
    )

    Parameters

    script
    Script code written in the specified report scripting language.
    Remarks
    This method is typically used when executing stand-alone reports that are not compiled into the application.  Injected code allows the report to access features such as custom calculation functions and data access modules in the calling application.
    Example
    public string addThisCode()
    {
        string sCode = "public string ShowACMessage()\"{return \"my Added Code\";}";
        return sCode;
    }
    
    private void rptAddCode_ReportStart(object sender, System.EventArgs eArgs)
    {
        this.AddCode(addThisCode());
    }
    Public Function addThisCode() As String
    	Dim sCode As String = "public string ShowACMessage()""{return ""my Added Code"";}"
    	Return sCode
    End Function
    
    Private Sub rptAddCode_ReportStart(sender As Object, eArgs As System.EventArgs)
    	Me.AddCode(addThisCode())
    End Sub
    See Also