首页 > Windows开发 > 详细

设置datagridview 单个单元格的背景色

时间:2019-12-15 14:41:22      阅读:147      评论:0      收藏:0      [点我收藏+]

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;

 

设置datagridview 单个单元格的背景色

原文:https://www.cnblogs.com/wfy680/p/12044027.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!