How to set the value of a Crystal Report text field at run time?

How to set the value of a Crystal report text field at run time. I have a text box in section 2 (page title) in a Crystal report, now I need to set the Text property of this text box at run time. Basically I have to pass the username in this text box.

+6
visual-studio crystal-reports
source share
3 answers

You can change the text of the text field at run time. You can use this:

using CrystalDecisions.CrystalReports.Engine; rptMyReport report = new rptMyReport(); TextObject to = (TextObject)report.ReportDefinition.Sections["Section2"].ReportObjects["textboxname"]; to.Text = newvalue; 

Another way is to use parameters.

+12
source share

If you have a username before opening the report, you can add a parameter field (string) to the report, and then put this field in the report where you want it to be displayed at run time. You just need to pass it to the report as a parameter, like any other parameter.

  Dim UserName As String = "BukHix" crDOC.SetParameterValue("UserName", UserName) 
+2
source share

try it

 ((TextObject)rpt.Section2.ReportObjects["Textbox"]).Text = "yourvalue"; 
+2
source share

All Articles