Crystal Report: Suppress Hightligthed fields on pr

2019-09-16 21:47发布

问题:

I have a crystal report which is previewed by the users (in a third party application) and they need some fields in this report highlighted (simple enough), but when they print the report to the B&W laser printer those fields must not be highlighted anymore.

Anyone know how to do this?

回答1:

It can be done by using a parameter of boolean data type which will control the appearance of the fields in preview or print mode. So for example in preview mode the parameter will be set to True and False in print mode. In the format editor there are some options to change the appearance of a field like its style, color etc. which can depend on the value of a parameter.

To find the format editor right click on the field and choose Format Object.

In the above image, the red rectangle shows the buttons which let you specify the appearance conditions.

To highlight a field you can change its color based on the preview or print mode.

First create a parameter and name it for example AppearanceParam

In the Field Explorer → right click on Parameter Fields → choose New → write the name of the parameter in the name box, choose its type to be boolean and click OK.

Click on the [x+2] button which is on the right side of the color in the format editor and write the following code there

if {?AppearanceParam} = true then
    crRed
else
    crBlack

The value of the parameter can be controlled programmatically before previewing or printing the report.