ActiveReports for .NET 3 Online Help Request technical support
Access Controls In Script
See Also
User Guide > How-To Section > Scripting > Access Controls In Script

Glossary Item Box

Use ((ControlType)rpt.Sections[SectionName].Controls[ControlName]) to type cast a control and access its properties.

If the project loads an RPX file into a new ActiveReport object, the script must refer to each control by using ((ControlType)rpt.Sections[SectionName].Controls[ControlName]). The reason for doing this is that a new ActiveReport object is not aware of the objects contained inside the RPX file. If you are using script in a report contained in a project and just creating a new instance of the report class you can use "rpt".

'Visual Basic Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _ MyBase.Load Dim rpt as new ActiveReport() rpt.LoadLayout("ActiveReport1.rpx") rpt.Run() Me.Viewer1.Document = rpt.Document End Sub //C# private void Form1_Load(object sender, System.EventArgs e) { ActiveReport rpt = new ActiveReport(); rpt.LoadLayout("ActiveReport1.rpx"); rpt.Run(); this.viewer1.Document = rpt.Document; } 'VB.NET Script Public Sub Detail1_Format() CType(rpt.Sections("Detail").Controls("TextBox1"), TextBox).Text = "Hello" End Sub //C# Script public void detail_Format() { ((TextBox)rpt.Sections["Detail"].Controls["TextBox1"]).Text = "Hello"; }

See Also

Concepts
Scripting

©2009. All Rights Reserved.