کد های زیر را نگاه کنید با کمی تغییرات می توانید کل row را رنگی کنید
using System.Drawing.Drawing2D;
ColorBlend colorBlend = null;
private void frmMain_Load(object sender, System.EventArgs e) {
colorBlend = new ColorBlend();
colorBlend.Colors = new Color[] {Color.Orchid, Color.White, Color.Orchid};
colorBlend.Positions = new float[] {0.0f, 0.5f, 1.0f};
}
private void gridView1_CustomDrawCell(object sender,
DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEv entArgs e) {
if(e.Column.FieldName != "RequiredDate") return;
//Get the cell's value
DateTime reqDate = (DateTime)e.CellValue;
if(reqDate < DateTime.Today) return;
//Calculate the text to display in the cell
string dispText;
if(reqDate > DateTime.Today)
dispText = ((TimeSpan)(reqDate - DateTime.Today)).Days.ToString() + " day(s) left";
else
dispText = e.DisplayText;
//Create the gradient brush
LinearGradientBrush brush = new LinearGradientBrush(e.Bounds,
Color.White, Color.Black, LinearGradientMode.ForwardDiagonal);
//Provide custom color blending
brush.InterpolationColors = colorBlend;
//Fill the cell's background
using(brush) {
e.Graphics.FillRectangle(brush, e.Bounds);
}
//Draw the cell's text
e.Graphics.DrawString(dispText, e.Appearance.Font, Brushes.Black, e.Bounds);
//Prohibit the default painting
e.Handled = true;
}
نتیجه کد بالا تصویر زیر است