Home General

Problem with changing font color

edited December 2010 in General

Hi,

I am currently using Rb 12.01. I want to change the font for a field to red
if that field is negative.

I have put my code into the OnPrint method - it is a simple if statement
setting the font. color to clRed if the value is less that 0 else to
ClBlack. I have stepped through the code and the selection works correctly,
but when the report previews, the font remains black regardless of the field
value.

I have changed the default font to Red and changed the code to set it to
black if the font is greater than or equal to 0 and then all fields are red.

Is this a bug, or what am I doing wrong?

Thanks
Rene

Comments

  • edited December 2010
    Hi Rene,

    Try moving this code to the Band.BeforePrint event rather than the OnPrint.
    You may be changing the font too late for the report to make a change before
    printing.


    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2010
    Oh, this is SO embarrassing!
    Looking at the code with fresh eyes after a night's sleep, I have realized
    that I omitted the field name! My code was setting font.color, not
    field.cont.color...

    So sorry for wasting your time! Perhaps some other end-of-year-weary soul
    may benefit from my stupidity!

    Kind Regards
    Rene


This discussion has been closed.