Change color of text object using formula in Cryst

2019-05-08 06:25发布

问题:

I want to change the color of the text in text object using formula in Crystal Report. I tried like

If {mnth_ttx.weight}>0 Then
  crRed;

But the color is not changing at run time. I wrote this condition under formula edit of weight text object. But not working. How to change the color of a text using formula

回答1:

Follow these steps:

  1. Right click field: select Format Field...
  2. Select Font tab, then click conditional-formula button to the right of the color picker
  3. Enter this formula: If {mnth_ttx.weight}>0 Then crRed Else crBlack


回答2:

Follow these steps:

  1. Right click field: select Format Field.
  2. select font tab.
  3. click on the X+2 box directly to the right of the color picker. The Formula Editor will open.
  4. Enter this formula:

    If {mnth_ttx.weight}>0 
      Then crRed 
    Else crBlack
    


回答3:

You can create a more advanced format using html First text field need to set the TextFormat property as crHTMLText With this the text field will interpret the html after being assigned in the formula you can put the following

if {?PARAMETER}=3 then    
If not IsNull ({TABLE.FIELD1}) Then
   "<p><b><font color='#00559c'>" & {TABLE2.FIELD1} & "</font></b></p>" & {TABLE2.FIELD2} & ": " & {TABLE2.FIELD2}
Else
    "<p><b><font color='#00559c'>" & {TABLE2.FIELD1} & "</font></b></p>"


回答4:

if x> 0 then
formula= color(159,255,159)
else 
formula = crRed
end if

'The values in the color(159,255,159) are color(red, green, blue). These are the numbers that you will see when you create a custom color.



回答5:

Right click field 1. Select format object 2. Goto Border 3. Select Background Colorado 4. Click OK.

That's it. You are done!