设置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;
}
}

posted @ 2019-12-21 17:24  清语堂  阅读(1986)  评论(0编辑  收藏  举报