A simple(?) line changes the text of a label (TextObject in Crystal Report):
((TextObject)rptDoc.ReportDefinition.ReportObjects["myTextObject"]).Text = "Here is my text.";
Here "myTextObject" is the name of the TextObject used in the report. To set the ObjectName, right click on the object >> format object >> object name.
string reportPatfh = "CrystalReport1.rpt";
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(reportPatfh); ((TextObject)rptDoc.ReportDefinition.ReportObjects["myTextObject"]).Text = "Here is my text.";
crystalReportViewer1.ReportSource = rptDoc;
There is another way:
((TextObject)rptDoc.ReportDefinition.Sections[2].ReportObjects["myTextObject"]).Text = "Here Is My Text";
3 Comments:
Thanks Yar. Since a long time i found solution of my query.
i knew that in vb 6 there is a function "settext" but i couldnt found same function in .net..
but u make my day..
Thanks Again.
@Anamika: my pleasure :)
Post a Comment