Adding a background colour

I would like to add a background colour to some fields based on a certain condition, that being the fastest time over a series of times. I tried to use an expression but as I'm using Boolean it could not convert the variant type.

The code is like this:

procedure MemoBestTimeOnBeforePrint(Sender: TfrxComponent);
begin
if <lapTimesData."fastestlap"> = <lapTimesData."Nr"> then
TfrxMemoview(Sender).font.style := fsUnderline
else
TfrxMemoview(Sender).font.style := 0;
end;

The example above will underline the fastest time, but how can I add a coloured background to it, such as grey? I just need to know the code I think.

Many thanks for any help.

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 7:46AM
    Use the memoview's colour property
  • hsmhsm
    edited January 2016
    This should do it. You don't need to cast it to a TfrxMemoView in this case, you can just use the memo's name.
    Note you must have an 'else' clause to set the color to something else if the condition is not met (even clNone) otherwise the first time your condition is met the colour will change but then it will stay changed for the rest of the report, regardless of the data in the following rows.
    procedure MemoBestTimeOnBeforePrint(Sender: TfrxComponent);
    begin
    if <lapTimesData."fastestlap"> = <lapTimesData."Nr"> then
       begin
       MemoBestTime.font.style := fsUnderline;
       MemoBestTime.color := clRed;
       end
    else
       begin
       MemoBestTime.font.style := 0;
       MemoBestTime.color := clGreen;
       end;
    end;
    

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.