簡體   English   中英

ActiveReports中文本框控件的簡單設置方法

[英]Simple setter for textbox control in ActiveReports

如何在ActiveReports 3.1中訪問TextBox控件。 當我使用ActiveReport 6或更高版本時,下一個代碼會像Textbox一樣工作(我的TextboxName屬性為"TextBox1" ),但是在3.0版本中,它的代碼不正確:

this.TextBox1.Text = "Test";

有編譯錯誤出現“在6.0中沒有TextBox1的定義”,它工作正常。 如何強制此代碼正確執行? 這是來自rpx文件的代碼

<?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>

這是錯誤 在此處輸入圖片說明

您可以確保報表中有一個名為“ TextBox1”的文本框控件嗎? 名稱在C#中區分大小寫。 也許有一個叫做“ textBox1”的代替。

看起來您在基於XML(.rpx)的報告中使用腳本,而不是在純粹基於代碼的報告中使用腳本。 在較舊版本的ActiveReports中使用基於XML的報表(.rpx文件)時,必須按如下所示通過集合訪問控件:

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

但是,在當前版本的ActiveReports(ActiveReports 7)中,此限制已被刪除,因此您可以編寫如下代碼:

this.TextBox1.Text = "Hello World";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM