我查了一下,ydsunny(小强) ( )是web的解决方法,在winform里,DataGridView没有RowDataBound事件,如果在winform里,如下修改:
private void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
if (e.RowIndex > = dataGridView1.Rows.Count - 1)
return;
DataGridViewRow dgr = dataGridView1.Rows[e.RowIndex];
try
{
if (dgr.Cells[ "列名 "].Value.ToString() == "比较值 ")
{
dgr.DefaultCellStyle.ForeColor = 设置的颜色;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
转载于:https://www.cnblogs.com/xiaofengfeng/archive/2011/05/04/2036721.html