Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set crystal report's textbox value at run time?

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.

like image 319
Student Avatar asked Mar 02 '11 22:03

Student


3 Answers

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.

like image 153
buda Avatar answered Nov 09 '22 15:11

buda


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)
like image 45
Buck Hicks Avatar answered Nov 09 '22 14:11

Buck Hicks


try this

((TextObject)rpt.Section2.ReportObjects["Textbox"]).Text = "yourvalue";
like image 2
Student Avatar answered Nov 09 '22 14:11

Student