Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TcxCustomDateEditProperties.OnGetDayState Event

In This Article

Enables you to customize the background color and font settings of individual day numbers displayed in the editor dropdown calendar.

#Declaration

Delphi
property OnGetDayState: TcxCalendarGetDayStateEvent read; write;

#Remarks

This event is fired for each day number to be displayed within the editor dropdown calendar. You can handle this event to customize the background color and font settings of individual day numbers. The following screenshot illustrates highlighted the first and fifteenth workdays of the month.

The Sender parameter provides access to the date editor whose calendar is about to be painted.

The ADate parameter specifies the date whose day number is about to be painted.

The AState parameter indicates the display state of the day number.

Customize the font settings and background color of the day number via the AFont and ABackgroundColor parameters.

Use the OnGetDayState event in combination with the OnGetDayOfWeekState event for more granular control over the appearance of day names and day numbers 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 week and then adjust them for specific days only.

The following code example shows how to handle the OnGetDayState event to highlight the first and fifteenth workdays of a month (as illustrated in the screenshot above).

Delphi
procedure <Form>.<DateEditProperties>GetDayState(Sender: TObject; ADate: TDateTime; AState: TCustomDrawState; AFont: TFont; var ABackgroundColor: TColor);
var
  AYear, AMonth, ADay: Word;
begin
  DecodeDate(ADate, AYear, AMonth, ADay);
  if (ADay in [1, 15]) and (DayOfTheWeek(ADate) in [1..5]) then
  begin
    ABackgroundColor := clYellow;
    AFont.Style := [fsBold];
  end;
end;
See Also