cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to programmatically override a formula used in a report?

inthegroove
Explorer
308

I want to programmatically change the color to Black when printing (FieldObject, TextObject).
I've found a way, but it's not perfect.

My Code here..
List<FieldObject> fldobjitems = rd.ReportDefinition.ReportObjects.OfType<FieldObject>().ToList();
foreach (FieldObject fldobj in fldobjitems)
{
if (fldobj.Color != System.Drawing.Color.Black) fldobj.Color = System.Drawing.Color.Black;
}
.
.
.


Formulas for Color are defined in some fields, but they are not changed.

select CurrentFieldValue
case "-":
RGB(0,0,0)
default:
RGB(255,0,0)

Is there any workaround?
thanks.

Accepted Solutions (1)

Accepted Solutions (1)

ido_millet
Active Contributor
0 Kudos

You need to change the expression -- not the property value.
That is possible to do, but it is easier to simply use a parameter to control the expression and simply feed a value into that parameter.

inthegroove
Explorer
0 Kudos

There are report files that are already in use,
but there is a case where a customer requests all text colors to be black, so I am looking for a way to solve it programmatically.
I've found some workarounds, but it seems that fields with 'Format Field -> Font -> Color - Formula' cannot be changed programmatically.
Still looking for a way.

Thank you for your reply.

ido_millet
Active Contributor
0 Kudos

At least with the .NET runtime I know from direct experience that it is possible to change that expression.
But it is simpler to add a parameter to the report.

You should be able to add an optional parameter to existing reports. Instruct the user to ignore that parameter.

inthegroove
Explorer
0 Kudos

I think the best way is to use the method and parameters I found appropriately.

thank you

Answers (1)

Answers (1)

DonWilliams
Active Contributor
0 Kudos

If you are using .NET then go here:

https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

See my test app:

how-to-parameters-in-crystal-reports-for-visual-studio-net

It has a drop down listbox that will get the formula, use it by cloning the object and then you can make changes to it.

Other than that as Ido suggested it may be simpler to just update their report

inthegroove
Explorer
0 Kudos

thanks for your reply.