CustomDrawObjectEventsArgs.Handled Property

Gets or sets whether an event is handled. If true, the default actions are not required.

Namespace: DevExpress.XtraSpreadsheet

Assembly: DevExpress.XtraSpreadsheet.v21.2.dll


public bool Handled { get; set; }

Property Value

Type Description

true if default painting isn’t required; otherwise, false.


The events used to custom paint the SpreadsheetControl’s elements fire before these elements are painted in their default manner. If the event parameter’s Handled property is set to true, default painting is not performed. Otherwise, the SpreadsheetControl’s standard drawing mechanism overrides any custom painting.

You can call the CustomDrawObjectEventsArgs.DrawDefault method in the event handler to use the default drawing mechanism to render an element, and then set Handled to true to paint custom drawing over default graphics.

The code example below shows how to use the CustomDrawCellBackground event to draw a custom shape over default rendering for cells that contain 0 in the “Units In Stock” column.


spreadsheetControl1.CustomDrawCellBackground += (s, e) =>
    if (e.Cell.ColumnIndex == 2 && e.Cell.Value == 0)
        int size = 10;
        e.BackColor = Color.LightPink;
        e.Handled = true;
        e.Cache.FillEllipse(Color.Red, new Rectangle(e.Bounds.Left + size, e.Bounds.Top + size / 2, size, size));
See Also