Search code examples
c#crystal-reports

How to Change text of Text Object in Crystal Report Programmatically


i got many same text objects in crystal report which i want to change text of them using c#.net this is my code:

TextObject textObj = (TextObject)MyReport.Sections[2].ReportObjects[3];

but i cant change text of textObj


Solution

  • text of text objects cant change my friend. i think that the best way is that you create another text object and then delete your first text object, try this code:

    TextObject textObj = (TextObject)MyReport.Sections[2].ReportObjects[3];
    string newString = "any thing which you want write as your text";
    TextObject newTextObj = MyReport.Sections[2].AddTextObject(newString, textObj.Left, textObj.Top);
    newTextObj.Height = textObj.Height;
    newTextObj.Width = textObj.Width;
    newTextObj.Font = textObj.Font;
    MyReport.Sections[2].DeleteObject(textObj);