Search code examples
c#crystal-reportscrystal-reports-xi

Setting crystal report text field on FormLoad


I am using Crystal Report's Crystal Report Viewer on Winforms. On my report there is a text field name recptNumber. I put a viewer on WinForm. What I want to set value of it when form loads. I can access value by doing :

RaseedLayout.secDetails.ReportObjects["txtRepRaseedNumber"]).Text = "۳۴۴۴۵۵";

but can't set the value at all.

How do I do it?

rptRaseed RaseedLayout = new rptRaseed();
MessageBox.Show(((TextObject)RaseedLayout.secDetails.ReportObjects["txtRepRaseedNumber"]).Text);
((TextObject)RaseedLayout.secDetails.ReportObjects["txtRepRaseedNumber"]).Text= "۳۴۴۴۵۵";
RaseedLayout.Refresh();

Solution

  • Try this :

    TextObject txt1 = (TextObject)RaseedLayout.ReportDefinition.Sections["YOURSECTIONHERE"].ReportObjects["txtRepRaseedNumber"];
    
    txt1.Text = "۳۴۴۴۵۵";
    

    Hope this works!