Color a field by color in nother field
Hedley
Peru
i have 2 fields in a table
alume
as1 char 3
as1c char 10
example
as1 value is 5
as1c value is clBlue
Memo alumEAS1 contains [alumE."AS1"]
procedure DetailData1OnBeforePrint(Sender: TfrxComponent);
begin
alumEAS1.font.color := <alumE."AS1C">
end;
i obtain an error "could not convert variant of type (string) into type (boolean)
what i am doing wrong ?
how it would be right
thanks
hedley
alume
as1 char 3
as1c char 10
example
as1 value is 5
as1c value is clBlue
Memo alumEAS1 contains [alumE."AS1"]
procedure DetailData1OnBeforePrint(Sender: TfrxComponent);
begin
alumEAS1.font.color := <alumE."AS1C">
end;
i obtain an error "could not convert variant of type (string) into type (boolean)
what i am doing wrong ?
how it would be right
thanks
hedley
Comments
font colors are colorconstants clred.claqua, etc. not strings so try
alumEAS1.font.color := (<alumE."AS1C">)
Dear gordk : i tried but i obteained the same mess error
could not convert variant of type (string) into type (boolean)
thanks
is not available in the internal functionsyou can work around this by either adding the function in a function lib, or using variables set on to the color field and one with no value at all
use the one with no value in report code to trigger the ogv event indelphi then use the delphifunction to return the color.
1) change the field type to longint or equivalent, store the the Tcolor value there, for example, dataset.fieldbyName('AS1C') := clBlue (or whatever color it is), and your line alumEAS1.font.color := <alumE."AS1C"> should work, if not, try
alumEAS1.font.color := cardinal(<alumE."AS1C">);
or
alumEAS1.font.color := TColor(<alumE."AS1C">);
Actually, try alumEAS1.font.color := TColor(<alumE."AS1C">); in your current code without changing the field definition anyway, maybe it will work.
2) If you can't change the field definition for whatever reason, create an IF...THEN to analyse each string case in your BeforePrint event:
if <alumE."AS1C"> = 'clBlue' then
alumEAS1.font.color := clBlue
else
if <alumE."AS1C"> = 'clRed' then
alumEAS1.font.color := clRed
else ...
Cheers, Alex
Alex :
1. in cardinal and Tcolor, i receive the message "too many parameters"
2. i'll do this, but i have about 50 fields to test and assign color, and it's a litle slow, and take about 5 seconds to display te report. this is why i tried to change the way to do it more parametric and faster
thanks
hedley
then code would look like
memo#.font.color := mycolor(<datasetname."fieldname">);
Gordk :
would you send me some tips to create the function lib ?
thanks
hedley
if you want to have them available from with in the ide build it as a component
good example is Stalker's additional function lib in the Binaries news group