SAP Knowledge Base Article - Public

1486928 - How to modify chart titles during run time in a VS .NET application

Symptom

Resolution

  • Use the InProc RAS SDK for .NET exposes more APIs which allow chart modifications at runtime
  • The following C# code will change the title of a chart in a report:
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
ISCDReportClientDocument rcd;
rpt.Load(path);
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;

Keywords

Forum thread , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To

Product

Crystal Reports 2008 V1 ; SAP Crystal Reports XI R2