Back to Devexpress

CalendarControl.CustomDrawDayNumberCell Event

windowsforms-devexpress-dot-xtrascheduler-dot-reporting-dot-calendarcontrol-3b19b6a9.md

latest5.7 KB
Original Source

CalendarControl.CustomDrawDayNumberCell Event

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

Namespace : DevExpress.XtraScheduler.Reporting

Assembly : DevExpress.XtraScheduler.v25.2.Reporting.dll

NuGet Package : DevExpress.Win.SchedulerReporting

Declaration

csharp
public event CustomDrawDayNumberCellEventHandler CustomDrawDayNumberCell
vb
Public Event CustomDrawDayNumberCell As CustomDrawDayNumberCellEventHandler

Event Data

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

PropertyDescription
BackgroundElementInfoGets or sets the skin element that is used to paint the background of the currently processed cell.
BoundsGets the painted element’s bounding rectangle.
ContentBoundsGets the bounds of the cell’s content (text).
DateGets the painted cell’s value. This property is obsolete. Use the DateTime property instead.
DateOnlyGets the painted cell’s DateOnly value.
DateTimeGets the painted cell’s DateTime value.
DisabledGets whether the painted cell is disabled.
HighlightedGets whether the currently processed cell is under the mouse cursor.
HolidayGets whether the painted cell corresponds to Saturday or Sunday.
InactiveGets whether the painted cell belongs to the previous or next month.
IsPressedGets whether the cell is currently pressed.
IsSpecialGets whether the cell corresponds to a “special” date.
SelectedGets a value indicating whether the processed day number cell is selected.
StateGets the current cell’s state.
StyleGets the painted date cell’s appearance settings.
TodayGets whether the painted cell corresponds to Today’s date.
ViewGets or sets the current View of data in the dropdown window.
ViewInfoContains information used for painting the current cell.

Remarks

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.

csharp
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);
    }
}
vb
Private Sub calendarControl1_CustomDrawDayNumberCell(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Calendar.CustomDrawDayNumberCellEventArgs)
    If e.Date.DayOfYear Mod 12 = 0 Then
        Dim p As Pen = e.Cache.GetPen(Color.Violet)
        Dim r As Rectangle = e.Bounds
        r.Inflate(-2, 0)
        r.Offset(3, 0)
        e.Cache.DrawRectangle(p, r)
    End If
End Sub

See Also

CalendarControl Class

CalendarControl Members

DevExpress.XtraScheduler.Reporting Namespace