Does anyone knows if it is possible to custom draw fields (basically the color) based on a specified condition? I would like to have my 'special fields' being draw in a different color from the one defined in AutomaticTextAttr.TextColor.
Usuall the best is it to apply the attribute durin mailmerge, see Contents.MergeAttr
To use the event to mark the text with red color use in case a field is negative use this code:
procedure TWPTBXForm.WPRichText1GetAttributeColor(Sender: TObject;
var CharStyle: TCharacterAttr; par: TParagraph; posinpar: Integer);
var txtobj: TWPTextObj; s : string;
begin
txtobj := WPRichText1.CodeInsideOf(par, posinpar, wpobjMergeField);
if txtobj <> nil then
begin
s := txtobj.EmbeddedText;
if (s<>'') and (s[1]='-') then
CharStyle.TextColor := clRed
else CharStyle.TextColor := clNone;
end;
end;
#2♥ 0
This category is archived. No new posts are possible.