Showing results for 
Search instead for 
Did you mean: 

CR2008 - Set chart titles during run time

Former Member
0 Kudos

Hello community!

Is there a way to change the chart titles during runtime with the fullversion?

I have the following code to change the text of the "FieldHeadingObject" and "TextObject" and this is working.

foreach (CrystalDecisions.CrystalReports.Engine.ReportObject repObject in sec.ReportObjects)
   if (repObject.Kind == ReportObjectKind.TextObject ||
       repObject.Kind == ReportObjectKind.FieldHeadingObject)
        ((CrystalDecisions.CrystalReports.Engine.TextObject)repObject).Text = "my new Text";

How can I change the titles of the chart object?

I know already that there is the class "ChartTextOptionsClass"

Does someone know how I could access the TextOptions in the ChartObject so that the new Titles are displayed in the report?

Thank you


View Entire Topic
Former Member
0 Kudos


I found the following code to access the properties.

CrystalDecisions.ReportAppServer.Controllers.ReportObjectController crRasObjectControler;
crRasObjectControler = report.ReportClientDocument.ReportDefController.ReportObjectController;

foreach (CrystalDecisions.ReportAppServer.ReportDefModel.ChartObject crRasReportObject
               in crRasObjectControler.GetReportObjectsByKind(CrReportObjectKindEnum.crReportObjectKindChart))
                crRasReportObject.ChartStyle.TextOptions.DataTitle = "my Data Title";
                crRasReportObject.ChartStyle.TextOptions.GroupTitle = "my Group Title";
                crRasReportObject.ChartStyle.TextOptions.Title = "my Title";

In the debuger, I see that the values are changed. How can those values be displayed?

Do I have to save/change/modify the chart object?

How can I make this?

Thank you for your help


Edited by: Alexander Frwirth on Jul 6, 2010 11:49 AM

Active Contributor
0 Kudos

You'll have to do a bit of cloning... The code below should give you a good start:

        CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        ISCDReportClientDocument rcd;
        rcd = rpt.ReportClientDocument;

        CrystalDecisions.ReportAppServer.ReportDefModel.ChartObject oldChart;
        CrystalDecisions.ReportAppServer.ReportDefModel.ChartObject newChart;
        oldChart = (ChartObject)rcd.ReportDefController.ReportObjectController.GetReportObjectsByKind(CrReportObjectKindEnum.crReportObjectKindChart)[0];
        newChart = (ChartObject)oldChart.Clone(true);
        newChart.ChartStyle.TextOptions.Title = "My New Chart Title";
        rcd.ReportDefController.ModifyChartObject(oldChart, newChart);

        CrystalReportViewer1.ReportSource = rpt;


Follow us on Twitter

Edited by: Ludek Uher on Jul 6, 2010 12:15 PM