Conditional background fill colour

I have created a report using C# code and want to change the background color based on the condition of two other fields. However the code does not work. It sets all the background color to orange though the values differ.

I tried using the code from this link but it did not work https://www.fast-report.com/en/forum/index....c=14573&hl=


Is there any thing I am doing wrong?

Comments

  • edited January 2019
    TextObject decemberTarget = new TextObject
                {
                    Name = "DecemberTarget",  
                    Left = 670.95f,
                    Width = 28.35f,
                    Height = 24.57f,
                    HorzAlign = HorzAlign.Right,
                    VertAlign = VertAlign.Center,
                    Font = new Font("Arial", 8),
                    Text = "[Data.DecemberTarget]",
            BeforePrintEvent = "DecemberTarget_BeforePrint"    
                };
    
    report.ScriptText = @"using System;
    using System.Drawing;
    namespace FastReport
    {  
      public class ReportScript
      {
        private void DecemberTarget_BeforePrint(object sender, EventArgs e)
        {
          int value = (int)Report.GetColumnValue(""Data.DecemberAchieved"");
          if (value < 6)
        DecemberTarget.FillColor = Color.Orange;
          else
              DecemberTarget.FillColor = Color.Green;
        }
      }
    }
    ";
    

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.