【发布时间】:2015-06-11 01:03:43
【问题描述】:
大家好,我想根据如下所示的某个值更改单元格索引,我在这里看到了很多文章,但是在 ASP.NET 中,这是一个 Windows 应用程序,我如何使用 Windows 桌面应用程序将其存档。 请注意我希望更改索引的列是动态创建的。谢谢 动态列代码创建
private void button3_Click(object sender, EventArgs e)
{
DataTable table = new DataTable();
adap.Fill(table);
dataGridView1.DataSource = table;
table.Columns.Add("RESULTS").Expression = "Iif(((ActualWeight >= (.96 * TargetWeight)) And (ActualWeight <= (1.04 * TargetWeight))),'GOOD''BAD'))
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells[7].Value.ToString() == "BAD")
row.Cells[7].Style.ForeColor = Color.Red;
//row.Cells["RESULTS"].Style.ForeColor = Color.Red;
}
}
【问题讨论】:
-
那么您是想在点击时更改它还是根据值更改它?
-
是的,先生,就像 cell[4]=='bad' ,color=='RED'
-
@Sheldon 这张桌子是什么? DataGridView 的名称是什么?
-
名称是dataGridView1
标签: c#