Search

Tuesday, March 2, 2010

To dynamically change the text at runtime in Crystal Report

To dynamically change the text at run time you will need to change the value of the TextObject programmatically. All report objects are accessed through the ReportDocument.ReportDefinition.ReportObjects collection.

1. Right-click Form1.cs in the Solution Explorer and select View Code
2. In the Form1 class, add the following code:

ReportDocument rd = new ReportDocument();

rd.Load(@"C:\\CrystalReport1.rpt");

((CrystalDecisions.CrystalReports.Engine.TextObject)rd.ReportDefinition.ReportObjects["text1"]).Text = "Italy Wins!!";

crystalReportViewer1.ReportSource = rd;

Blog Archive

Contributors