Setting Font Color
In the detail line of a report, I want to set the font color based on a color value stored in a separate field in the detail record. I don't want to display the separate field, just use it to set the font color of the displayed field. Like this...
Record
Value 1
Value 2
Font Color
Set the text of Value 1 to the color contained in Font Color.
Record
Value 1
Value 2
Font Color
Set the text of Value 1 to the color contained in Font Color.
Comments
set up the conditional highlighting
<datasetname."fieldname">
record positioning will depend upon band being connected to the dataset or manual positiong
by code.
typical code of an obp event of a databand.
if <datasetname."fieldname"> = 1 then memo1. propertyname := whatever value required.
txtReason.Font.Color := frxDBDetail."DisplayColor";
and I keep getting an Identifier expected error message.
I've also tried the following in the OBP event of the MemoView (after assigning the "DisplayColor" data field to the memo view)...
Memo2.Font.Color := Memo2.Value;
but that doesn't seem to work either (aside from the fact that I don't want to display the actual "DisplayColor" value in the report).
So what am I missing here?
Memo2.Font.Color := Memo2.Value;
does set the color of the font, but uses the value of the previous record, not the current record.
(In case I didn't mention it before - the color is user selected and so can be any value. I'm not trying to set the font Red on one condition and Blue on another. I'm trying to set the font to the color the user selected and stored in a data record.)
also be carefull when and where you use the value property of a memoview's memo
value returns the value of the last variable or datafield processed in the memo.
So how would I go about doing this?
ie
databand1____________________________ connected to ds1 with 2memoviews
| memo1 | | memo2 |
[ds1."empid"] [ds1."reasontxt"]
typical code
var mycolor:integer;
procedure databand1OnBeforePrint(Sender: TfrxComponent);
begin
mycolor := <ds1."color">;
case mycolor of
1:
begin
memo2.font.color := clred;
end;
2:
begin
memo2.font.color := clmaroon;
end;
// repeat for each color possibility of color box
end;
begin
end.
i would temporarily display in a third memo the [ds1."color"] field
to see what values it is returning.
you might get a suprise as to what the underlying field actually is returning
Thanks.