C# 如何设置DEV控件的gridview 某个单元格的字体颜色
但源人长久 2018-12-18 07:32:38 找了好多,不是改变整行就是整列,终于解决了
其实只要判断一下是不是要改变的列就行了
private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
{
string accountQuantity = gridView1.GetRowCellValue(e.RowHandle, "xy").ToString();
string[] sArray = accountQuantity.Split('/');
int xydg = 0;
int zjz = 0;
foreach (string aa in sArray)
{
try
{
xydg = Int32.Parse(aa);
}
catch
{
xydg = 150;
}
zjz++;
}
if (140 < xydg && zjz == 1)
{
//sqoy 改变指定单元格颜色
if (e.Column.FieldName == "xy") //判断是否是要改变的单元格
{
e.Appearance.ForeColor = Color.Red;
}
}
else if (90 < xydg && zjz == 2)
{
if (e.Column.FieldName == "xy")
{
e.Appearance.ForeColor = Color.Red;
}
}
else
{
}
}