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?
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?
This discussion has been closed.
Comments
Hello!
Inside the BeforePrint handler, always set the Fill property of the current instance (TextObject) of `sender` (not just the global object), and be sure to include both if/else branches:
private void Cell_BeforePrint(object sender, EventArgs e) { var cell = (TextObject)sender; int achieved = Convert.ToInt32(Report.GetColumnValue(“Data.DecemberAchieved”)); int target = Convert.ToInt32(Report.GetColumnValue(“Data.DecemberTarget”)); cell.Fill = (achieved < target) ? new SolidFill(Color.Orange) : new SolidFill(Color.LightGreen); }