Change color of dbfield

edited 2:52PM in FastReport 4.0
Hi

I am new to Fastreports.

How do I change the colour of a dbfield on a report according to more than one condition. I know I can use highlighting. But that caters only for one condition.

Regards
Karen

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 2:52PM
    write code in the obp event of the memoview or the band containing the memoview.
  • edited 2:52PM
    Thank you for replying.

    As I said I am a newbie. So what you replied makes no sense to me. Can you pls explain.
  • gpigpi
    edited 2:52PM
    procedure Memo1OnBeforePrint(Sender: TfrxComponent);
    begin
      if <YourDatasetName."YourFieldName"> > 1000 then Memo1.Color := clRed;                                                                                     
    end;
    
  • edited May 2014
    I am using version 4.13.2. And it is an Embarcadero version on XE4.

    It does not have any event handlers. So can not use events on the report components. Only have events on the report it self, like onbeforeprint etc.
  • gordkgordk St.Catherines On. Canada.
    edited 2:52PM
    yes the embarcedero version is limited
  • edited 2:52PM
    So any other way I can do it. I have the following code in my onbeforeprint:
    if MatchStr(sender.Name,['dsPairedTTestCONS1','dsPairedTTestCONS2','dsPairedTTestCONS3','dsPairedTTestCONS4','dsPairedTTestCONS5']) then
      begin
             if TFrxMemoView(sender).value = 'HS' then TFrxMemoView(sender).Font.Color := clred
        else if TFrxMemoView(sender).value = 'PS' then TFrxMemoView(sender).Font.Color := clblue
        else if TFrxMemoView(sender).value = 'NS' then TFrxMemoView(sender).Font.Color := clblack
        else                                           TFrxMemoView(sender).Font.Color := clblack;
    
        if  TFrxMemoView(sender).value = 'HS' then
          TFrxMemoView(sender).Font.Style := [fsBold]
        else if TFrxMemoView(sender).value = 'PS' then
          TFrxMemoView(sender).Font.Style := [fsBold]
        else if TFrxMemoView(sender).value = 'NS' then
          TFrxMemoView(sender).Font.Style := []
        else
          TFrxMemoView(sender).Font.Style := [];
      end;
    

    But this results in changing the next row's color ??!!

  • gpigpi
    edited 2:52PM
    You can't get TFrxMemoView(sender).value in TfrxReport.OnBeforePrint event, try to use frxReport1.Calc(TFrxMemoView(sender).Text)
  • edited 2:52PM
    I get the following error if I change my code to frxReport1.Calc(TFrxMemoView(sender).Text). Please see file attached for error.

  • edited 2:52PM
    Bumping this post up.

    Anybody able to help me?
  • gordkgordk St.Catherines On. Canada.
    edited 2:52PM
    Karen read this topic it may help you understand what is required
    http://www.fast-report.com/en/forum/?p=/discussion/11839
  • gpigpi
    edited 2:52PM
    replace [,] with <,> in the expression

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.