Asign color to text by data field
Hedley
Peru
Hi..
i use this sentences to asign color to text
procedure alum1mAS1OnBeforePrint(Sender: TfrxComponent);
begin
if <alumE."AS1">='7' then alum1mAS1.font.color:=clBlack
else if <alumE."AS1">='8' then alum1mAS1.font.color:=clMaroon
else if <alumE."AS1">='5' then alum1mAS1.font.color:=clRed
else if <alumE."AS1">='6' then alum1mAS1.font.color:=clGreen
else if <alumE."AS1">='9' then alum1mAS1.font.color:=clNavy
else if <alumE."AS1">='10' then alum1mAS1.font.color:=clNavy
else alum1mAS1.font.color:=clRed
end;
and this is for 20 fields, and for 25 records... then ... 500 at last
if the colors change, i need to change the sentences...
is posible that the "color" will be a another field in the data
alum1mAS1.font.color := colorfromdata ( clblack/clMaroon/clRed/clNavy ....... )
Thanks a lot
Hedley
i use this sentences to asign color to text
procedure alum1mAS1OnBeforePrint(Sender: TfrxComponent);
begin
if <alumE."AS1">='7' then alum1mAS1.font.color:=clBlack
else if <alumE."AS1">='8' then alum1mAS1.font.color:=clMaroon
else if <alumE."AS1">='5' then alum1mAS1.font.color:=clRed
else if <alumE."AS1">='6' then alum1mAS1.font.color:=clGreen
else if <alumE."AS1">='9' then alum1mAS1.font.color:=clNavy
else if <alumE."AS1">='10' then alum1mAS1.font.color:=clNavy
else alum1mAS1.font.color:=clRed
end;
and this is for 20 fields, and for 25 records... then ... 500 at last
if the colors change, i need to change the sentences...
is posible that the "color" will be a another field in the data
alum1mAS1.font.color := colorfromdata ( clblack/clMaroon/clRed/clNavy ....... )
Thanks a lot
Hedley
Comments
Font.color is a cardinal value, this is for example is black:
alum1mAS1.font.color:= 0;
And this is red:
alum1mAS1.font.color:= $0000FF; // or 255;
So, what you need is a field (integer type) with the color value:
alum1mAS1.font.color:= <alumE."DataColor">;
Or at even a function that calculates it for you:
alum1mAS1.font.color:= GetTheColor(<alumE."AS1">);
function GetTheColor(pData: variant): DWORD;
var lData: integer;
begin
lData:= vartoint(pData);
case lData of
0: result := 0;
1: result := $33;
etc...
end;
end;
thanks a lot...
but how i know the cardinals number for the other colours
may be i use a numbers code from html text ?
thanks again...
Hedley
However, it's possible that they are coded inversely (RGB instead of BGR), so put as many colors as you can and test it.
If the codes are inverted, you can convert it, but I'm not going to teach you how to do that, you will have to do a bit of research (and learning...)