两步:
1.注册GridView的CustomDrawFooterCell事件
2.在事件响应中,根据条件修改e.Appearance.ForeColor
例子如下:
public FormMMIRPWTEST()
{
InitializeComponent();
gridView1.CustomDrawFooterCell += gridView1_CustomDrawFooterCell;
}
void gridView1_CustomDrawFooterCell(object sender, DevExpress.XtraGrid.Views.Grid.FooterCellCustomDrawEventArgs e)
{
switch (e.Column.Name)
{
case "MemoEdit"://找到对应的列名
if (e.Info.Value.ToString().Equals("2"))
{
e.Appearance.ForeColor = Color.Red;
}
else
{
e.Appearance.ForeColor = Color.Green;
}
break;
case "gridColumnNum"://找到对应的列名
var val = 0;
if (int.TryParse(e.Info.Value.ToString(),out val) && val<100)
{
e.Appearance.ForeColor = Color.Red;
}
else
{
e.Appearance.ForeColor = Color.Yellow;
}
break;
case "MemoEditEx"://找到对应的列名
e.Info.Value = e.Info.SummaryItem.Tag;
//e.Info.DisplayText = "hello DisplayText";
e.Appearance.ForeColor = Color.Yellow;
break;
default:
break;
}
}
效果:
不知道为什么设置e.Appearance.BackColor无效(而在非统计行中有效),知道的大侠麻烦告知。