KB Article A857
Visible to All Users

How to paint the expand buttons within the CustomDrawGroupRow event in exactly the same manner as the XtraGrid does

Description:
Your GridMainDemo project (the CustomDraw module) shows how to paint expand buttons using images. Is there another way to paint these buttons?

Answer:
It is possible to paint expand buttons using exactly the same methods the XtraGrid uses itself. Here is some sample code showing how this can be implemented:

C#
private void gridView1_CustomDrawGroupRow(object sender, DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs e) { DevExpress.XtraGrid.Views.Grid.GridView view; DevExpress.XtraGrid.Views.Grid.ViewInfo.GridGroupRowInfo ee; DevExpress.Utils.Drawing.OpenCloseButtonInfoArgs ocb; DevExpress.XtraGrid.Drawing.GridGroupRowPainter painter; view = sender as DevExpress.XtraGrid.Views.Grid.GridView; ee = e.Info as DevExpress.XtraGrid.Views.Grid.ViewInfo.GridGroupRowInfo; ocb = new DevExpress.Utils.Drawing.OpenCloseButtonInfoArgs(e.Cache, ee.ButtonBounds, ee.GroupExpanded, ee.AppearanceGroupButton, DevExpress.Utils.Drawing.ObjectState.Normal); if(!ee.ButtonBounds.IsEmpty) { painter = e.Painter as DevExpress.XtraGrid.Drawing.GridGroupRowPainter; painter.ElementsPainter.OpenCloseButton.DrawObject(ocb); } e.Handled = true; }
Visual Basic
Private Sub GridView1_CustomDrawGroupRow(ByVal sender As Object, ByVal e As _ DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs) Handles GridView1.CustomDrawGroupRow Dim view As DevExpress.XtraGrid.Views.Grid.GridView Dim ee As DevExpress.XtraGrid.Views.Grid.ViewInfo.GridGroupRowInfo Dim ocb As DevExpress.Utils.Drawing.OpenCloseButtonInfoArgs Dim painter As DevExpress.XtraGrid.Drawing.GridGroupRowPainter view = CType(sender, DevExpress.XtraGrid.Views.Grid.GridView) ee = CType(e.Info, DevExpress.XtraGrid.Views.Grid.ViewInfo.GridGroupRowInfo) ocb = New DevExpress.Utils.Drawing.OpenCloseButtonInfoArgs(e.Cache, ee.ButtonBounds, _ ee.GroupExpanded, ee.AppearanceGroupButton, DevExpress.Utils.Drawing.ObjectState.Normal) If Not ee.ButtonBounds.IsEmpty Then painter = CType(e.Painter, DevExpress.XtraGrid.Drawing.GridGroupRowPainter) painter.ElementsPainter.OpenCloseButton.DrawObject(ocb) End If e.Handled = True End Sub

See Also:
How to align summary values displayed in a group row to the corresponding columns

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.