设置DataGridView的单元格颜色

RowPrePaint事件:

private void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)

{
if ("不存在" == this.dataGridView1.Rows[e.RowIndex].Cells["库位"].Value.ToString())
{
this.dataGridView1.Rows[e.RowIndex].Cells["库位"].Style.BackColor = Color.MediumPurple;
}
}

猜你喜欢

转载自www.cnblogs.com/wfy680/p/12077555.html