Search code examples
c#devexpressdevexpress-windows-ui

How to set custom text to a GroupRow in the CustomDrawGroupRow event of a DevExpress GridControl?


I'm looking for a way of setting the GroupRow text inside the CustomDrawGroupRow event without setting e.Handled = true because I need the base drawing to also be applied:

this.gridView.CustomDrawGroupRow += (s, e) => 
{
    /* set the GroupRow text here without using e.Handled = true */
}

I've tried using e.Graphics.DrawString but then I can't use e.Appearance.BackColor because I need to set e.Handled = true to draw the string which disables it


Solution

  • You need to cast the e.Info as GridGroupRowInfo and set GridGroupRowInfo.GroupText to your value:

    using DevExprss.XtraGrid.Views.Grid.ViewInfo;
    
    ...
    
    this.gridView.CustomDrawGroupRow += (s, e) => 
    {
        GridGroupRowInfo groupInfo = e.Info as GridGroupRowInfo;
        groupInfo.GroupText = "Custom group text";
    }