locked
how to set the value of a ITextObject.... RRS feed

  • Question

  • User-1100530492 posted
    I put a ITextObject on the report templete, I want to change its value dynamicly, but i don't know how to set the value, can anyone tell me how to set the value or give me a better idea, thx!
    Friday, August 22, 2003 11:05 AM

Answers

  • User1450743321 posted

    Here is the c# version: -

    To change the value of ITextObject of Crystal Report (Visual Studio 2008) at run time you have to: -

    1. Create a object of ITextObject
    2. Assign the source object with typecast to new object
    3. Now use the new object and set all the properties (like Text, Font etc…)
    CrystalDecisions.CrystalReports.Engine.TextObject txtReportHeader;
    txtReportHeader = MyReport.ReportDefinition.ReportObjects["txtHeader"] as TextObject;
    txtReportHeader.Text = "All Vouchers Print - Prabhat";

    http://prabhat.me/2009/11/06/change-the-value-of-itextobject-of-crystal-report-at-runtime/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 6, 2009 10:30 AM

All replies

  • User1070929020 posted
    its something similar to this.. Dim oRpt As New crPO() Dim crReportObject As ReportObject Dim crTextObject As TextObject For Each crReportObject In oRpt.Section1.ReportObjects If crReportObject.Kind = ReportObjectKind.TextObject Then crTextObject = CType(ReportObject, TextObject) crTextObject.Text = "dfd" End If Next but i am still trying to figure it out.
    Monday, September 15, 2003 2:46 PM
  • User1450743321 posted

    Here is the c# version: -

    To change the value of ITextObject of Crystal Report (Visual Studio 2008) at run time you have to: -

    1. Create a object of ITextObject
    2. Assign the source object with typecast to new object
    3. Now use the new object and set all the properties (like Text, Font etc…)
    CrystalDecisions.CrystalReports.Engine.TextObject txtReportHeader;
    txtReportHeader = MyReport.ReportDefinition.ReportObjects["txtHeader"] as TextObject;
    txtReportHeader.Text = "All Vouchers Print - Prabhat";

    http://prabhat.me/2009/11/06/change-the-value-of-itextobject-of-crystal-report-at-runtime/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, November 6, 2009 10:30 AM
  • User-319574463 posted

    Thank you for the Code snippet. Your code example was very helpful. I included a null value value test at the suggestion of ReSharper.

    var reportDocument = new ReportDocument { FileName = this.ReportPath };

    var fred = reportDocument.ReportDefinition.ReportObjects["FRED"] as TextObject;
    if (fred != null)
    {
      fred.Text = "Fred's name";
    }

    Monday, December 5, 2011 4:57 AM