private void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
DataGridViewRow dgr = dataGridView1.Rows[e.RowIndex]; 
try
{
if (dgr.Cells["onduty1"].Value.ToString() == "" || dgr.Cells["onduty1"].Value.ToString() == null)
{
dgr.Cells["onduty1"].Style.BackColor = Color.Red;
}
 
}
catch (Exception ex)
{

 MessageBox.Show(ex.Message); 
}
}

 

方法二:

dataGridView1.Rows[index].Cells["测试结果"].Style.BackColor = Color.White;

 

private void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
DataGridViewRow dgr = dataGridView1.Rows[e.RowIndex]; 
try
{
if (dgr.Cells["onduty1"].Value.ToString() == "" || dgr.Cells["onduty1"].Value.ToString() == null)
{
dgr.Cells["onduty1"].Style.BackColor = Color.Red;
}
 
}
catch (Exception ex)
{

 MessageBox.Show(ex.Message); 
}
}

 

方法二:

dataGridView1.Rows[index].Cells["测试结果"].Style.BackColor = Color.White;

 

相关文章:

  • 2022-12-23
  • 2021-12-19
  • 2021-08-25
  • 2021-11-04
  • 2021-12-03
  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-26
  • 2022-12-23
  • 2021-06-20
  • 2021-12-12
  • 2021-10-12
  • 2021-05-02
  • 2022-12-23
相关资源
相似解决方案