Topic: Field with multi color text based on a condition

Hi,
Is it possible in Fast Reports using an on before print event  to change the font color based on the data. For example 'Flight' would be clRed and 'Cruise' would clBlue and so on up to say 6 different possible differnt colors. So far all I can do is change it only on one condition .

begin
if Copy(<Report."TableName.FieldName">,1,1)='F' then
ReportActionItemsType.Font.Color:= clRed
else
ReportActionItemsType.Font.Color:=clBlack;
end;

Any help would be appreciated. Thanks

2 (edited by prahousefamily 2018-09-24 08:26:00)

Re: Field with multi color text based on a condition

Please attach project or screen shot for help
Or Download Example Report Scipt

Example Report Script

procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
IF Copy(<Report."id">,Length(<Report."id">),1) = '1'   
Then Memo6.Font.Color := clred
Else If Copy(<Report."id">,Length(<Report."id">),1) = '2'  
Then Memo6.Font.Color := clgreen
Else If Copy(<Report."id">,Length(<Report."id">),1) = '3'  
Then Memo6.Font.Color := clgray      
Else If Copy(<Report."id">,Length(<Report."id">),1) = '4'  
Then Memo6.Font.Color := clblue
Else If Copy(<Report."id">,Length(<Report."id">),1) = '5'  
Then Memo6.Font.Color := clyellow
Else If Copy(<Report."id">,Length(<Report."id">),1) = '6'  
Then Memo6.Font.Color := clmaroon
Else If Copy(<Report."id">,Length(<Report."id">),1) = '7'  
Then Memo6.Font.Color := clnavy
Else If Copy(<Report."id">,Length(<Report."id">),1) = '8'  
Then Memo6.Font.Color := clolive
Else If Copy(<Report."id">,Length(<Report."id">),1) = '9'  
Then Memo6.Font.Color := cllime          
Else Memo6.Font.Color := clblack ;                              
  
end;

begin
Post's attachments

Attachment icon TreeView.zip 503.71 kb, 431 downloads since 2018-09-24 

My Visual Database : I Love You
Easy For Beginner Student For Me