编程更改文本对象示例代码

类别:.NET开发 点击:0 评论:0 推荐:

using CrystalDecisions.CrystalReports.Engine;

private const string REPORT_NAME = @"..\..\CrystalReportAnalysis.rpt";
private const string TEXT_OBJECT_NAME = @"Text1";

private void Form1_Load(object sender, System.EventArgs e)
{
 report = new ReportDocument();
 report.Load(REPORT_NAME);
 report.Refresh();

 crvChart.ReportSource = report;
}

private void btnChangeText_Click(object sender, System.EventArgs e)
{
 TextObject text;
 
 text = GetTextObject(TEXT_OBJECT_NAME);

 text.Text = "Hello, Haibo.NET!";

 crvChart.RefreshReport();
}

private TextObject GetTextObject(string reportObjectName)
{
 TextObject text;

 // 按名称获取 ReportObject,将其转换为 TextObject,
 //并返回此对象。
 text = report.ReportDefinition.ReportObjects[reportObjectName] as TextObject;
 if (text != null) return text;
 else return null;
}

本文地址:http://com.8s8s.com/it/it45303.htm