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.v20.1.dll

Declaration

public bool Handled { get; set; }
Public Property Handled As Boolean

Property Value

Type Description
Boolean

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

Remarks

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.

Spreadsheet_Default_And_Custom_Draw_Cells


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