请问,DataGridView如何这样改变单元格颜色?
DataGridView绑定到datatable
如何使DataGridView随着datatable数据的变化,使得有数据的单元格颜色是红色,没有值(null)的单元格是默认的白色
谢谢!!
[解决办法]
CellFormatting事件,设置e.CellStyle.xxxx
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.Value.ToString() == "yes") { e.CellStyle.ForeColor = Color.Red; } }
[解决办法]
楼上正解!