Skip to main content

How to: Custom Draw Group Rows

The code below applies grouping by the “Category_Name” column and changes the background and foreground colors for even group rows.

GridControl - CustomDrawGroupRows

using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using System.Drawing.Drawing2D;

private void Form3_Load1(object sender, EventArgs e) {
    CustomDrawGroupRow(gridControl1, gridView1);
}

public static void CustomDrawGroupRow(GridControl gridControl, GridView gridView) {
    gridView.Columns["Category_Name"].Group();

    // Handle this event to paint group rows manually
    gridView.CustomDrawGroupRow += (s, e) => {
        if (e.RowHandle % 2 == 0) {
            e.Appearance.BackColor = Color.BlanchedAlmond;
            e.Appearance.ForeColor = Color.DimGray; ;
        }
    };
}