Sta*_*ros 10 c# devexpress xtragrid
如何更改DevExpress网格视图的字体颜色?我发现的所有解决方案都是关于改变前景色和背景色.
我希望有一个红色字体,以防单元格中的值为负.
有什么建议吗?
Ste*_*cya 10
签署RowCellStyle事件并在那里设置ForeColor
private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
{
if(e.Column.FieldName == "Field2")
{
var data = gridView1.GetRow(e.RowHandle) as Sample;
if(data == null)
return;
if (data.Field2 < 0)
e.Appearance.ForeColor = Color.Red;
}
}
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
19995 次 |
| 最近记录: |