CSDN博客

img haibodotnet

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

发表于2003/11/16 10:45:00  3679人阅读

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;
}

0 0

相关博文

我的热门文章

img
取 消
img