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

14,609

Solution 1

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.

Solution 2

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)

Solution 3

try this

((TextObject)rpt.Section2.ReportObjects["Textbox"]).Text = "yourvalue";
Share:
14,609
Student
Author by

Student

Updated on June 14, 2022

Comments

  • Student
    Student almost 2 years

    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.