Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Change ppmemo color on input value

edited June 2007 in General
?I would like color of the ppmemo to change according to the value of
the input, ie for values 0-4, color = clGreen, for values 5-10, color =
clRed.

I have gotten this to work with shapes, but not with ppmemo's.

Thank you.



--- posted by geoForum on http://delphi.newswhat.com

Comments

  • edited June 2007
    Hi Daneel,

    1. Be sure you have the Transparent property of the memo set to False.

    2. Use the TppMemo.Color to alter the background color of the memo
    component.

    ppMemo1.Transparent := False;
    ppMemo1.Color := clGreem;

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2007
    Hi Nico,

    Thank you, it worked very well!

    Regards,
    Daneel

    =



    --- posted by geoForum on http://delphi.newswhat.com
  • edited June 2007
    The solution only worked the first time, subsequent tests failed.

    here is what I did:

    procedure ppMemo19OnPrint;
    begin
    if ppMemo19.lines.text = '5' then
    ppMemo19.Transparent := False;
    ppMemo19.Color := clRed;
    end;
    end;

    Thank you.



    --- posted by geoForum on http://delphi.newswhat.com
  • edited June 2007
    Hi Daneel,

    Try using the Band.BeforePrint event to set the color of the Memo. Also,
    note that you will need to set the color back to the default if the
    condition is not met so other memos will not remain the changed color.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2007
    Hi, There is a minor syntax error of this code that I cannot find,
    please see if you can spot it, error tells me:
    'Line5: Expected 'not' or 'or' but found 'ppMemo19' instead

    procedure DetailBeforePrint;
    begin
    if ppMemo19.lines.text = '5' then
    ppMemo19.Transparent := False
    ppMemo19.Color := clRed;
    else
    ppMemo19.Color := clWhite;
    end;
    end;

    Thank you
    Regards,
    Daneel



    --- posted by geoForum on http://delphi.newswhat.com
  • edited June 2007
    You need a begin...end around your if statement.

    procedure DetailBeforePrint;
    begin
    if ppMemo19.lines.text = '5' then
    begin
    ppMemo19.Transparent := False;
    ppMemo19.Color := clRed;
    end
    else
    ppMemo19.Color := clWhite;
    end;


    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.