[一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/3227351.html]
1 private void ChangBackColor()
{
if (dataGridView1.Rows.Count > )
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells["列名"].Value.ToString() == "条件")
{
row.Cells["列名"].Style.ForeColor = System.Drawing.Color.Red;
row.DefaultCellStyle.ForeColor = Color.Red; //改变整行的
}
}
DataGridViewCellStyle dgvcs = new DataGridViewCellStyle();
dgvcs.BackColor = Color.Green;
dataGridView1.Columns["列名"].DefaultCellStyle = dgvcs; //整列
}
}
05-08 08:10