Skip to main content
A newer version of this page is available. .

GridView.CustomDrawRowIndicator Event

Enables you to custom paint cells within the row indicator panel.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v19.2.dll

Declaration

[DXCategory("CustomDraw")]
public event RowIndicatorCustomDrawEventHandler CustomDrawRowIndicator

Event Data

The CustomDrawRowIndicator event's data class is RowIndicatorCustomDrawEventArgs. The following properties provide information specific to this event:

Property Description
Appearance Gets the painted element’s appearance settings. Inherited from CustomDrawEventArgs.
Bounds Returns a value specifying limits for the drawing area. Inherited from CustomDrawEventArgs.
Cache Provides methods to paint on drawing surfaces in GDI+ and DirectX modes. See DirectX hardware acceleration to learn more. Inherited from CustomDrawEventArgs.
Graphics A GDI+ drawing surface. Use the CustomDrawEventArgs.Cache property instead if you enable the DirectX hardware acceleration. Inherited from CustomDrawEventArgs.
Handled Gets or sets a value specifying whether an event was handled and that the default element painting is therefore not required. Inherited from CustomDrawEventArgs.
Info Gets information about the painted row indicator.
Painter Gets the painter object that provides the default element painting mechanism. Inherited from CustomDrawObjectEventArgs.
RowHandle Gets the handle of the row whose corresponding element is being painted. Inherited from RowObjectCustomDrawEventArgs.

The event data class exposes the following methods:

Method Description
DefaultDraw() Performs default painting of an element. Inherited from CustomDrawEventArgs.

Remarks

The CustomDrawRowIndicator event is raised each time a row indicator cell needs to be repainted. The cell’s row can be identified using the RowObjectCustomDrawEventArgs.RowHandle parameter. Note that this property returns the master row’s handle when painting a cell corresponding to a detail section. When the band header or column header indicator cell is painted, the parameter returns the GridControl.InvalidRowHandle field value. If you need to identify whether the cell corresponds to the band header panel, column header panel or a detail section, use the View’s GridView.CalcHitInfo method. Pass the cell’s top-left corner coordinates as the method’s parameter. The returned object’s GridHitInfo.HitTest property can be used to identify the indicator cell type. Please refer to the Hit Information topic for details.

See the Custom Painting Basics and Custom Painting Scenarios topics for information on using custom draw events.

Important

Never change cell values or modify the control’s layout on this event, or any other event designed to tune the control’s appearance. Any action that causes a layout update can cause the control to malfunction.

Online Video

WinForms Grid: Custom Row Indicators.

Example

This example illustrates how to apply custom colors to row indicators. You can test this sample in the Custom painting - CustomDrawRowIndicator Data Grid demo.

CustomDraw - RowIndicator

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

public static void CustomDrawRowIndicator(GridControl gridControl, GridView gridView) {
    gridView.IndicatorWidth = 50;
    // Handle this event to paint RowIndicator manually
    gridView.CustomDrawRowIndicator += (s, e) => {
        if (!e.Info.IsRowIndicator) return;
        GridView view = s as GridView;
        e.Handled = true;

        e.Appearance.BackColor = view.FocusedRowHandle == e.RowHandle ? Color.Chocolate : Color.MediumSpringGreen;
        e.Appearance.FillRectangle(e.Cache, new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, e.Bounds.Width - 4, e.Bounds.Y - 4));
        if (e.Info.ImageIndex < 0) return;
        ImageCollection ic = e.Info.ImageCollection as ImageCollection;
        Image indicator = ic.Images[e.Info.ImageIndex];
        e.Cache.DrawImage(indicator, new Rectangle(e.Bounds.X + 20, e.Bounds.Y + 6, indicator.Width, indicator.Height));
    };
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the CustomDrawRowIndicator event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also