How to set crystal report's textbox value at run time. I have a textbox in section2 (page header) in crystal report, now I have to set Text property of this textbox at run time. Basically I have to pass user name in this textbox.
You can change textbox text in runtime. You can use this:
using CrystalDecisions.CrystalReports.Engine;
rptMyReport report = new rptMyReport();
TextObject to = (TextObject)report.ReportDefinition.Sections["Section2"].ReportObjects["textboxname"];
to.Text = newvalue;
The another way is to use parameters.
If you have the user name before the report opens you can add a parameter field (string) to the report and then put that field on the report where you want it to appear at runtime. You will just need to pass it into the report as a parameter just like you would any other parameter.
Dim UserName As String = "BukHix"
crDOC.SetParameterValue("UserName", UserName)
try this
((TextObject)rpt.Section2.ReportObjects["Textbox"]).Text = "yourvalue";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With