I beieve you can use the following code:
void gridView1_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e) {
var cellBounds = ((DevExpress.XtraGrid.Views.Grid.ViewInfo.GridCellInfo)e.Cell).Bounds;
DrawCellBorder(e.Graphics, Brushes.Red, cellBounds, 1);
}
void DrawCellBorder(Graphics g, Brush borderBrush, Rectangle cellBounds, int borderThickness) {
Rectangle innerRect = Rectangle.Inflate(cellBounds, -borderThickness,- borderThickness);
g.ExcludeClip(innerRect);
g.FillRectangle(borderBrush, cellBounds);
}
Note that e.Bounds
returns a cell content rectangle within the CustomDrawCell event handler (not the entire cell bounds).