windowsforms-devexpress-dot-xtraeditors-dot-simplebutton-850dfc5d.md
Allows you to draw the button manually.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXCategory("Appearance")]
public event EventHandler<ButtonCustomDrawEventArgs> CustomDraw
<DXCategory("Appearance")>
Public Event CustomDraw As EventHandler(Of ButtonCustomDrawEventArgs)
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. |
The following code snippet handles the CustomDraw event to change the button’s hovered background:
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;
}
}
Private Sub simpleButton1_CustomDraw(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.ButtonCustomDrawEventArgs)
If e.Info.State = DevExpress.Utils.Drawing.ObjectState.Hot Then
e.Cache.FillRectangle(Brushes.Orange, e.Bounds)
e.DefaultDrawImage()
e.DefaultDrawText()
e.Handled = True
End If
End Sub
See Also