TcxCustomDateEditProperties.OnGetDayOfWeekState Event
Enables you to customize the background color and font settings of individual days of the week displayed in the editor dropdown calendar.
Declaration
property OnGetDayOfWeekState: TcxCalendarGetDayOfWeekStateEvent read; write;
Remarks
This event is fired for each day name and day number to be displayed within the editor dropdown calendar. You can handle this event to customize the background color and font settings of these elements for certain days of the week. The following screenshot illustrates weekend days (Saturday and Sunday highlighted) and days of the current month emphasized in bold.
The Sender parameter provides access to the date editor whose calendar is about to be painted.
The ADayOfWeek parameter identifies the day of week whose element (day name or related day number) is about to be painted.
The AState parameter indicates the display state of the element.
Customize the font settings and background color of the element via the AFont and ABackgroundColor parameters.
Use the OnGetDayOfWeekState event in combination with the OnGetDayState event for more granular control over the element appearance within the calendar. When both these events are handled, the OnGetDayOfWeekState event fires for a day number before the OnGetDayState event, allowing you to specify the appearance settings for certain days of the week and then adjust them for specific days only.
The following code example shows how to handle the OnGetDayOfWeekState event to highlight weekend days (as illustrated in the screenshot above).
procedure <Form>.<DateEditProperties>GetDayOfWeekState(Sender: TObject; ADayOfWeek: TDay; AState: TCustomDrawState; AFont: TFont; var ABackgroundColor: TColor);
begin
if ADayOfWeek in [dSaturday, dSunday] then
begin
AFont.Color := clRed;
// Days outside of the currently selected month are grayed out
if not(cdsGrayed in AState) then
AFont.Style := [fsBold];
end;
end;