110,534
社区成员
发帖
与我相关
我的任务
分享
foreach (DataGridViewRow r in dataGridView1.Rows)
{
if ((string)(r.Cells["部门属性"].Value) == "基本生产部门")
{
r.DefaultCellStyle.Font = new Font("宋体", 12, FontStyle.Bold);
r.DefaultCellStyle.ForeColor = Color.Red;
}
}
//在DataGridView的RowPrePaint事件中加入下面的代码就可以了
if (Convert.ToString(this.dataGridView1.Rows[e.RowIndex].Cells["部门属性"].Value) == "基本生产部门")
{
this.dataGridView1.Rows[e.RowIndex].DefaultCellStyle.Font = new Font("宋体", 12, FontStyle.Bold);
this.dataGridView1.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Red;
}