Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I got many some text objects in crystal report which i want to change text of them using c#.net this is my code :
C#
TextObject txtReportHeader;
txtReportHeader = objRpt.ReportDefinition.ReportObjects["Text1"] as TextObject;
txtReportHeader.Text = "Pa";

but I cant change text of txtReportHeader.
Thank you
Posted

1 solution

CSS
CrystalDecisions.CrystalReports.Engine.TextObject txtReportHeader;
txtReportHeader = MyReport.ReportDefinition.ReportObjects["txtHeader"] as TextObject;
txtReportHeader.Text = "My Text";



Do this way while generating the report and you will get your output
 
Share this answer
 
Comments
axim007 12-Mar-18 1:00am    
I am using the code same way as follows
CrystalDecisions.CrystalReports.Engine.TextObject txtReportHeader;
txtReportHeader = MyReport.ReportDefinition.ReportObjects["txtHeader"] as TextObject;
txtReportHeader.Text = "My Text";

but it says "Index was outside the bounds of the array"

i dont know why this is happening.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900