首先介绍下设置指定单元格代码:
private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e) { DataTable dt = (DataTable)gridControl1.DataSource; //gridview里是读取数据库数据,这里是将gridview数据转化成 datatable for (int i = 0; i < dt.Rows.Count; i++) //循环数据 { if (e.RowHandle == i&&e.Column.FieldName == "SHZT") //这个是判断行数和FileName为SHZT的列 { string shzt = dt.Rows[i]["SHZT"].ToString(); //取出SHTZ列数据 if (shzt == "审核不通过") 判断数据 { e.Appearance.ForeColor = Color.Red; //设置字体为红色 } } }