我有一个数据网格,我填充了某些值,然后检查这些值是否在限制范围内。将有x40列。我将单元格设为绿色/红色以通过/不通过
public void colourTableCell(int rowIndex, double lowLimit, double highLimit)
{
dataGridView1.Rows[0].Cells[1].Style.BackColor = Color.White;
for (int i = 1; i < dataGridView1.Columns.Count; i++)
{
dataGridView1.Columns[i].Width = 60;
DataGridViewCell cell = dataGridView1.Rows[rowIndex].Cells[i];
if (cell.Value is double)
{
double value = (double)cell.Value;
if ((value < lowLimit) || (value > highLimit))
{
cell.Style.BackColor = Color.Red;
failStatus[i] = true;
}
else
cell.Style.BackColor = Color.LightGreen;
cell.Style.ForeColor = Color.Black;
}
}
}
然后我将结果写入文本文件
for (int index = 1; index < dataTable.Columns.Count; index++)
{
sw.Write((failStatus[index]) ? "FAIL; " : "PASS; ");
}
写入之后我想要做的是在每个索引的flowLayoutPanel中以5x8结构显示红色图像或绿色图像。因此图像代表索引,它将是通过/绿色或失败/红色。