Skip to Content
0
Feb 14, 2014 at 12:07 PM

Accessing individual elements of a textobject

29 Views

Hi,

I'm using Crystal Reports 2008 in a .Net application.

I'm looping through each object in the report and applying colours at run time. We have certain text headings, fields, borders etc use use a single colour. We want to be able to change that colour without having to touch the individual reports.

So, the general approach is that if the object's font is not black then replace the colour with the new colour.

foreach (Crystal.ReportObject oO in oCurrentReport.ReportDefinition.ReportObjects)

{

if (oO is CrystalDecisions.CrystalReports.Engine.LineObject)

{

...

}

else if ((oO is CrystalDecisions.CrystalReports.Engine.TextObject))

{

...

}

}

This works fine for most objects but doesn't work for certain textobjects with multiple fonts:

[{@ReferenceHeading}: {@Ref}]

{@ReferenceHeading}: is specified to have a colour.

{@Ref}: is specified to be black

This results as one textobject - my question is how can I access each element of the textobject?

Crystal Reports itself can detect the difference because it does apply the different design time colouring.

I can't split out the objects from the textobject because {@ReferenceHeading} is a variable length and I want to maintain the look.

Any ideas?