我正在尝试突出显示DataGridView中的特定行。
但以下代码无效:
foreach (DataGridViewRow row in DataGridView1.Rows)
{
if (row.Cells["Job No"].Value.ToString().Equals("Sub Total"))
{
row.DefaultCellStyle.BackColor = Color.Red;
}
}
有什么想法吗?谢谢!
答案 0 :(得分:0)
foreach (DataGridViewRow row in DataGridView1.Rows)
{
if (row.Cells["Job No"].Value.ToString().Equals("Sub Total"))
{
DataGridView1.rows[row.index].DefaultCellStyle.BackColor = Color.Red;
}
}