以代码记录一下,怎样利用RowCellStyle事件给DevExpress的GridControl单元格设置背景色,先给GridView加RowCellStyle事件:
this.GridView.RowCellStyle += new DevExpress.XtraGrid.Views.Grid.RowCellStyleEventHandler(this.GridView_RowCellStyle);
接着事件代码设置背景色:
void GridView_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
{
var name = e.Column.Name;
if (!name.Contains("Main") && !name.Contains("DJ") && !name.Contains("BZ"))
{
e.Appearance.BackColor = Color.FromArgb(255, 255, 224);
//e.Appearance.BackColor2 = Color.FromArgb(255, 255, 224);//如果设置渐变色,就再设置这个参数。
}
}
以上就是知道不在开发过程中记录的“怎样利用RowCellStyle事件给DevExpress的GridControl单元格设置背景色”。