如果要将某列满足一条件,并且将这一列的Color设为特定的
private void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
StyleFormatCondition cn;
cn = new StyleFormatCondition(FormatConditionEnum.LessOrEqual, gridView1.Columns["UnitPrice"], null, 18);
cn.Appearance.BackColor = Color.Yellow;
gridView1.FormatConditions.Add(cn);
}
如果要将行的条件满足某列的值,将该行的COLOR变化
private void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e){
DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
if (e.RowHandle >= 0)
{
decimal category = decimal.Parse(view.GetRowCellDisplayText(e.RowHandle, view.Columns["Amount"]));
string sfFlag = view.GetRowCellDisplayText(e.RowHandle, view.Columns["sfFlag"]);
string tUser = view.GetRowCellDisplayText(e.RowHandle, view.Columns["TUser"]);
if (category < 0||sfFlag== "退费"||tUser!="")
{
e.Appearance.BackColor = Color.Red;
}
}
}
如果是将行中的几列改变:
private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e){
DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
if (e.RowHandle >= 0)
{
If (e.Column.FieldName == "Count" || e.Column.FieldName == "Unit Price"){decimal category = decimal.Parse(view.GetRowCellDisplayText(e.RowHandle, view.Columns["Amount"]));
if (category < 0){e.Appearance.BackColor = Color.DeepSkyBlue
e.Appearance.BackColor2 = Color.LightCyan }}
}