//启用事件 this.gridView1.CustomDrawCell += new DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventHandler(this.gridView1_CustomDrawCell); private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) { if (e.Column.FieldName.Equals("age"))//列名称 { DevExpress.XtraGrid.Views.Grid.ViewInfo.GridCellInfo cellInfo = e.Cell as DevExpress.XtraGrid.Views.Grid.ViewInfo.GridCellInfo; if (cellInfo.IsDataCell) { if (double.Parse(cellInfo.CellValue.ToString()) < 20)//年龄小于20 { e.Appearance.BackColor = Color.OrangeRed; } else if (double.Parse(cellInfo.CellValue.ToString()) < 100)//年龄小于100 { e.Appearance.BackColor = Color.YellowGreen; } else { e.Appearance.BackColor = Color.Gold; } } } }
GridControll自定义绘制表格颜色
于 2022-06-23 16:48:53 首次发布