ActiveReports 6 Online Help
AddNamedItem Method
Example 

The name of the new object.
The value of the new object.
Adds an object to the script's global namespace.  This method allows scripts to become aware of custom classes contained within a project.  Once an item has been added, the script can use the objectName string to reference the object and the functions contained within the class.
Syntax
'Declaration
 
Public Sub AddNamedItem( _
   ByVal objectName As String, _
   ByVal objectReference As Object _
) 
public void AddNamedItem( 
   string objectName,
   object objectReference
)

Parameters

objectName
The name of the new object.
objectReference
The value of the new object.
Remarks

This method allows you to add objects such as data layer or business objects from the calling application into the report scripting context.  For example, you might have an Order class that contains a method for computing sales tax.  When you print the order you can pass an Order class instance to the report to allow you to call that method from the report script.

This method is typically used when running reports in stand-alone mode and not compiled into the application.

Example
//Add this code to the Class File
public class clsMyItem 
{ 
      public clsMyItem() 
      { 
      } 
      public string getMyItem() 
      { 
            return "Hello"; 
      } 
} 

//Add this code to the report
private void rptAddNamedItem_ReportStart(object sender, System.EventArgs eArgs) 
{ 
      this.AddNamedItem("myItem", new clsMyItem()); 
}
'Add this code to the Class File
Public Class clsMyItem 
      Public Function getMyItem() As String 
            getMyItem = "Hello" 
      End Function 
End Class 

'Add this code to the report
Private Sub rptAddNamedItem_ReportStart(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.ReportStart 
      Me.AddNamedItem("myItem", New clsMyItem())
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
AddCode Method
ScriptLanguage Property

Send Feedback