gridView1_CustomDrawCell与gridView1_RowCellStyle都可以且用法一样。但是CustomDrawCell更稳定
private void gridView1_CustomDrawCell(object sender, RowCellStyleEventArgs e) { DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView; //列名=a,值=1的标记为绿色 if (e.CellValue.ToString() == "1" && e.Column.FieldName.ToString().Equals("a")) { e.Appearance.BackColor = Color.FromArgb(128, 255, 128); e.Column.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss"; } }
时间: 2024-10-29 03:27:56