CalendarControl.CustomDrawDayNumberCell Event

Provides the ability to custom paint dates in the Calendar control.

Namespace: DevExpress.XtraScheduler.Reporting

Assembly: DevExpress.XtraScheduler.v21.1.Reporting.dll

Declaration

public event CustomDrawDayNumberCellEventHandler CustomDrawDayNumberCell

Event Data

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

Property Description
BackgroundElementInfo Gets or sets the skin element that is used to paint the background of the currently processed cell.
Bounds Gets the painted element’s bounding rectangle.
Cache Gets an object that specifies the storage for the most used pens, fonts and brushes.
ContentBounds Gets the bounds of the cell’s content (text).
Date Gets the painted cell’s value.
Disabled Gets whether the painted cell is disabled.
Graphics Gets an object used to paint.
Handled Gets or sets a value specifying whether default painting is prohibited.
Highlighted Gets whether the currently processed cell is under the mouse cursor.
Holiday Gets whether the painted cell corresponds to Saturday or Sunday.
Inactive Gets whether the painted cell belongs to the previous or next month.
IsPressed Gets whether the cell is currently pressed.
IsSpecial Gets whether the cell corresponds to a “special” date.
Selected Gets a value indicating whether the processed day number cell is selected.
State Gets the current cell’s state.
Style Gets the painted date cell’s appearance settings.
Today Gets whether the painted cell corresponds to Today’s date.
View Gets or sets the current View of data in the dropdown window.
ViewInfo Contains information used for painting the current cell.

The event data class exposes the following methods:

Method Description
DefaultDraw() Draws the processed cell according to the default algorithm.

Remarks

Note

Use the CustomDrawDayNumberCellEventArgs.Cache object for custom painting. Do not use the CustomDrawDayNumberCellEventArgs.Graphics object.

This code snippet illustrates how you can handle the CalendarControl.CustomDrawDayNumberCell event of the CalendarControl to highlight each 12th day of the year, by enclosing it with a hollow violet rectangle.

View Example

private void calendarControl1_CustomDrawDayNumberCell(object sender, 
    DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs e)
{
    if (e.Date.DayOfYear % 12 == 0)
    {
        Pen p = e.Cache.GetPen(Color.Violet);
        Rectangle r = e.Bounds;
        r.Inflate(-2, 0);
        r.Offset(3, 0);
        e.Cache.DrawRectangle(p, r);
    }
}
See Also