ActiveReports for .NET 3 Online Help Request technical support
Add Named Item
See Also
User Guide > How-To Section > Scripting > Add Named Item

Glossary Item Box

Use the AddNamedItem method to access class files in a project.

The AddNamedItem method is used to allow the script to gain access to functions in a class file contained within a project. This can be useful for allowing secure information such as a database connection string or a SQL query string to be used in the script without having to save it into the RPX file.

'Visual Basic
Public Class clsMyItem 
      Public Function getMyItem() As String 
            getMyItem = "Hello" 
      End Function 
End Class 

//C#
public class clsMyItem 
{ 
      public clsMyItem() 
      { 
      } 
      public string getMyItem() 
      { 
            return "Hello"; 
      } 
}

'Visual Basic
Private Sub rptAddNamedItem_ReportStart(ByVal sender As Object, ByVal e As System.EventArgs) _
	Handles MyBase.ReportStart 
      me.AddNamedItem("myItem", new clsMyItem()) 
End Sub 

//C#
private void rptAddNamedItem_ReportStart(object sender, System.EventArgs eArgs) 
{ 
      this.AddNamedItem("myItem", new clsMyItem()); 
}


'VB.NET Script
Public Sub Detail_Format() 
     rpt.Label1.Text = myItem.getMyItem()
End Sub

//C# Script
public void Detail_Format() 
{ 
     rpt.Label1.Text = myItem.getMyItem(); 
}

See Also

Concepts
Scripting

©2009. All Rights Reserved.