Question

How can I get access to TextBox control in ActiveReports 3.1. When I use ActiveReport 6 or newer next code work like a charm(I have Textbox with Name property "TextBox1") but in 3.0 release it's code are incorrect:

this.TextBox1.Text = "Test";

There is compile error appear "there is no definition of TextBox1"(in 6.0) it work fine. How can I force this code to execute correctly? Here is a code from rpx file

<?xml version="1.0" encoding="utf-16"?>
<ActiveReportsLayout Version="3.1" PrintWidth="9360" DocumentName="ARNet Document" ScriptLang="C#" MasterReport="0">
  <StyleSheet>
    <Style Name="Normal" Value="font-family: Arial; font-style: normal; text-decoration: none; font-weight: normal; font-size: 10pt; color: Black" />
    <Style Name="Heading1" Value="font-size: 16pt; font-weight: bold" />
    <Style Name="Heading2" Value="font-family: Times New Roman; font-size: 14pt; font-weight: bold; font-style: italic" />
    <Style Name="Heading3" Value="font-size: 13pt; font-weight: bold" />
  </StyleSheet>
  <Sections>
    <Section Type="PageHeader" Name="PageHeader1" Height="360" BackColor="16777215" />
    <Section Type="Detail" Name="Detail1" Height="2880" BackColor="16777215">
      <Control Type="AR.Field" Name="TextBox1" Left="1700.787" Top="1247.244" Width="1360.63" Height="340.1574" Text="TextBox1" />
    </Section>
    <Section Type="PageFooter" Name="PageFooter1" Height="360" BackColor="16777215" />
  </Sections>
  <ReportComponentTray />
  <Script><![CDATA[public void Detail1_Format()
{
    this.TextBox1.Text = "test";
}public void ActiveReport_ReportStart()
{

}


]]></Script>
  <PageSettings />
  <Parameters />
</ActiveReportsLayout>

and here is the error enter image description here

Was it helpful?

Solution

Looks like you're using script in an XML-based (.rpx) report instead of a purely code-based report. When using XML-based reports (.rpx files) in older versions of ActiveReports you must access the controls via collections as follows:

((DataDynamics.ActiveReports.TextBox)rpt.Sections["Detail1"].Controls["TextBox1"]).Text = "Hello World";

However, in the current version of ActiveReports (ActiveReports 7) this limitation has been removed so you can write code as follows:

this.TextBox1.Text = "Hello World";

OTHER TIPS

Can you make sure that there is a textbox control named 'TextBox1' in the report? The names are case sensitive in C#. Maybe there is one called 'textBox1' instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top