Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

SimpleButton.CustomDraw Event

Allows you to draw the button manually.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v24.2.dll

NuGet Package: DevExpress.Win.Navigation

#Declaration

[DXCategory("Appearance")]
public event EventHandler<ButtonCustomDrawEventArgs> CustomDraw

#Event Data

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

Property Description
Bounds Gets button bounds.
Info Gets information about the drawn button.
Painter Provides access to the object that performs paint operations. Inherited from ObjectCustomDrawEventArgs.

The event data class exposes the following methods:

Method Description
DefaultDrawBackground() Draws the button background in its default appearance.
DefaultDrawImage() Draws the button image in its default appearance.
DefaultDrawText() Draws button text in its default appearance.

#Remarks

The following code snippet handles the CustomDraw event to change the button’s hovered background:

WinForms SimpleButton - CustomDraw Event

void simpleButton1_CustomDraw(object sender, DevExpress.XtraEditors.ButtonCustomDrawEventArgs e) {
    if(e.Info.State == DevExpress.Utils.Drawing.ObjectState.Hot) {
        e.Cache.FillRectangle(Brushes.Orange, e.Bounds);
        e.DefaultDrawImage();
        e.DefaultDrawText();
        e.Handled = true;
    }
}
See Also