coloring text

HedleyHedley Peru
edited 11:20PM in FastReport 4.0
Please , how i can print diferent color text depending it's value

example

red if value is "NS"
green if value is "S"
and so on....

Thanks

Hedley

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 11:20PM
    either add code to obp event of band or object test datafield value and set font color accordingly
    or set the the objects conditional highliting props.
    see the user manual under formatting,highlight.
  • HedleyHedley Peru
    edited 11:20PM
    thanks

    Hedley
  • HedleyHedley Peru
    edited 11:20PM
    gordk wrote: »
    either add code to obp event of band or object test datafield value and set font color accordingly
    or set the the objects conditional highliting props.
    see the user manual under formatting,highlight.

    Please, i tried but i obtained a box filled red with the text black instead of red text

    on case the field value is NS,S,B,D or O, the color of text change

    the fields is [alum1m."AS1"]

    i need to obtain something like this

    fastrep.JPG

    please.. help
  • gordkgordk St.Catherines On. Canada.
    edited 11:20PM
    if you were using conditional highlighting editor you probably specified the color in the wrong section of the dialog
  • HedleyHedley Peru
    edited 11:20PM
    gordk wrote: »
    if you were using conditional highlighting editor you probably specified the color in the wrong section of the dialog
    Dear gordk :

    alum1mAS1OnBeforePrint content is

    begin
    alum1mAS1.Font.Color:=clRed
    end.

    and its work

    if alum1mAS1.Value ='B' then alum1mAS1.Font.Color:=clRed dont work

    if [alum1mAS1.Value] ='B' then alum1mAS1.Font.Color:=clRed dont work

    if (alum1mAS1.Value)='B' then alum1mAS1.Font.Color:=clRed dont work

    if <alum1m."AS1">='B' then alum1mAS1.Font.Color:=clRed dont work

    how is the correct sintaxt to compare

    thanks

    hedley

  • gordkgordk St.Catherines On. Canada.
    edited 11:20PM
    if <alum1m."AS1">='B' then alum1mAS1.Font.Color:=clRed else alum1mAS1.Font.Color:= clblack;
    this should work when used in the obp event of either the band or memoview.
    you will need an if statement for each possible value of the field alum1m."as1" note
    either use an else portion as above or reset to a certain color in the oap event of the memo.
  • HedleyHedley Peru
    edited February 2009
    gordk wrote: »
    if <alum1m."AS1">='B' then alum1mAS1.Font.Color:=clRed else alum1mAS1.Font.Color:= clblack;
    this should work when used in the obp event of either the band or memoview.
    you will need an if statement for each possible value of the field alum1m."as1" note
    either use an else portion as above or reset to a certain color in the oap event of the memo.

    Dear gordk :

    The Code for

    alum1mAS1:TfrxMemoView
    alum1mAS1OnBeforePrint

    begin
    if (<alum1m."AS1">)='NS' then alum1mAS1.Font.Color:=clRed else alum1mAS1.Font.Color:=clGreen
    end.

    but always its prints Green, like this image
    fastrep.JPG

    but you can see that exist values "NS", then it must be in Red

    i change the if statement for case

    begin
    case <alum1m."AS1"> of
    'BB':alum1mAS1.Font.Color:=clBlack;
    'DD':alum1mAS1.Font.Color:=clMaroon;
    'NS':alum1mAS1.Font.Color:=clRed;
    'OO':alum1mAS1.Font.Color:=clBlue;
    'SS':alum1mAS1.Font.Color:=clGreen;
    else alum1mAS1.Font.Color:=clYellow
    end;
    end.

    but now all the text are black...

    Hedley
  • gordkgordk St.Catherines On. Canada.
    edited 11:20PM
    you can't use case statements with strings
  • HedleyHedley Peru
    edited 11:20PM
    gordk wrote: »
    you can't use case statements with strings

    Dear gordk :

    The Code for

    alum1mAS1:TfrxMemoView
    alum1mAS1OnBeforePrint

    begin
    if (<alum1m."AS1">)='NS' then alum1mAS1.Font.Color:=clRed else alum1mAS1.Font.Color:=clGreen
    end.

    but always its prints Green, like this image
    fastrep.JPG

    but you can see that exist values "NS", then it must be in Red

    Hedley
  • gordkgordk St.Catherines On. Canada.
    edited 11:20PM
    if the memo that displays NS is not being switched to red font color
    then your datafield is not returning "NS' since you have centered the text in the memo object
    it is possible that it may be returning something like ' NS' or 'NS ' that has leading or trailing blanks.

    if (<alum1m."AS1">)='NS' this could be written
    if <alum1m."AS1"> ='NS'
  • HedleyHedley Peru
    edited 11:20PM
    gordk wrote: »
    if the memo that displays NS is not being switched to red font color
    then your datafield is not returning "NS' since you have centered the text in the memo object
    it is possible that it may be returning something like ' NS' or 'NS ' that has leading or trailing blanks.

    if (<alum1m."AS1">)='NS' this could be written
    if <alum1m."AS1"> ='NS'

    Dear gordk :

    please explain to me something i dont understand

    alum1mAS1:TfrxMemoView
    alum1mAS1OnBeforePrint
    begin
    if <alume."AS1">='D' then alum1mAS1.Font.Color:=clBlue else alum1mAS1.Font.Color:=clFuchsia
    end.

    the values of de registers are
    D
    O
    S
    B

    The first time i execute preview the report ( in design mode ) all are blue

    after that, the next preview all are fuchsia... why ?

    where are the problem....

    I need D Blue, O Green, S Red and B Fuchsia

    thanks

    Hedley
  • gordkgordk St.Catherines On. Canada.
    edited 11:20PM
    you are changing the design paramaters untill the data meets another statement that changes the color value it will stay on the new color.
    you can reset it to a basic value in an "else" portion or use the oap event of the object.
    you need multiple if statements to set up each possibile value of the datafield.
    you could use a case statement if your test value was numeric.
  • HedleyHedley Peru
    edited 11:20PM
    gordk wrote: »
    you are changing the design paramaters untill the data meets another statement that changes the color value it will stay on the new color.
    you can reset it to a basic value in an "else" portion or use the oap event of the object.
    you need multiple if statements to set up each possibile value of the datafield.
    you could use a case statement if your test value was numeric.
    Dear gordk :

    i found the error ....

    i dont know why, but it do not create the procedure
    procedure alum1mAS1OnBeforePrint(Sender: TfrxComponent);

    then all the sentences are in the wrong place...

    i create a new form to test, and i see that the procedure was created...
    wrote the sentences and it works...

    this is the final

    procedure alum1mAS1OnBeforePrint(Sender: TfrxComponent);
    begin
    if <alumE."AS1">='B' then alum1mAS1.font.color:=clBlack
    else if <alumE."AS1">='D' then alum1mAS1.font.color:=clMaroon
    else if <alumE."AS1">='NS' then alum1mAS1.font.color:=clRed
    else if <alumE."AS1">='S' then alum1mAS1.font.color:=clGreen
    else if <alumE."AS1">='O' then alum1mAS1.font.color:=clNavy
    else alum1mAS1.font.color:=clNone
    end;

    i test the case sentence and it works too... but i finally do with if sentences....

    thanks a lot, and i'm sorry for your time

    Hedley

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.