Back to Devexpress

How to: Paint Background of Numbers in DateEdit Using Skin Element

windowsforms-9483-controls-and-libraries-editors-and-simple-controls-examples-how-to-paint-background-of-numbers-in-dateedit-using-skin-element.md

latest1.3 KB
Original Source

How to: Paint Background of Numbers in DateEdit Using Skin Element

  • Oct 25, 2019

The following example shows how to paint the background of numbers in a DateEdit control using the Editors.EditorButton skin element. The background is changed via the CustomDrawDayNumberCellEventArgs.BackgroundElementInfo property.

The result is shown below:

csharp
using DevExpress.Skins;

private void dateEdit1_DrawItem(object sender, DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs e) {
    dE = sender as DateEdit;
    e.BackgroundElementInfo.Element = 
        EditorsSkins.GetSkin(dE.LookAndFeel.ActiveLookAndFeel)[EditorsSkins.SkinEditorButton];
}
vb
Imports DevExpress.Skins

Private Sub DateEdit1_DrawItem(ByVal sender As Object, _
  ByVal e As DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs) _
  Handles DateEdit1.DrawItem
    dE = TryCast(sender, DateEdit)
    e.BackgroundElementInfo.Element = EditorsSkins.GetSkin(dE.LookAndFeel.ActiveLookAndFeel)(EditorsSkins.SkinEditorButton)
End Sub