C1.C1Report Namespace > C1Report Class > AddScriptObject Method : AddScriptObject(String,Object) Method |
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.
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(); }
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