Posted 21 January 2021, 12:38 pm EST
I am dynamically creating cells, which correctly shows the data on the report. The DataTable that is the data source has columns called Value1…Value{n-1} based on the number of columns returned. What I would like to do is color the text in the cell based on the value of another field. So if the “Result” value in the DataTable is “P”, I would like the font color to be green. Otherwise, I would like it to be red. Here is the code I have. Is there a way I can bind a method to check the value of the data bound to the cell, or some other way to evaluate the data passed to each cell during the binding process?
for (int i = 1; i < columns.Count; i++) { textbox = new GrapeCity.ActiveReports.SectionReportModel.TextBox(); textbox.Name = "row" + (i).ToString(); textbox.DataField = $"Value{i}"; textbox.Location = new PointF(1.4f + (i * 0.3f), 0.0f); textbox.Size = new SizeF(0.3f, 0.3f); // TODO: Color text based on results //if (row["Result"].ToString() == "P") //{ // textbox.ForeColor = System.Drawing.Color.Green; //} //else //{ // textbox.ForeColor = System.Drawing.Color.Red; //} ar.Sections[4].Controls.Add(textbox); }