OnGetMonthBoldInfo
Description
The event allows you to highlight certain days in the calendar.
procedure OnGetMonthBoldInfo (Sender: TObject; Month, Year: Cardinal; var MonthBoldInfo: Cardinal);
Examples
// highlight days in the calendar, if January 2020 is shown
procedure Form1_MonthCalendar1_OnGetMonthBoldInfo (Sender: TObject; Month, Year: Cardinal; var MonthBoldInfo: Cardinal);
begin
if (Month=1) and (Year=2020) then
TdbMonthCalendar(Sender).BoldDays([1,3,4,6,8,10], MonthBoldInfo);
end;
// Highlighting days in the calendar that are present in the database table
procedure Form1_MonthCalendar1_OnGetMonthBoldInfo (Sender: TObject; Month, Year: Cardinal; var MonthBoldInfo: Cardinal);
var
AStr: array of string;
AByte: Array of byte;
sMonth, s: string;
i, c: integer;
begin
// getting the days from database to be highlighted in the calendar
sMonth := IntToStr(Month);
if Length(sMonth)=1 then sMonth := '0' + sMonth;
s := SQLExecute( 'SELECT group_concat(strftime(''%d'', "DateField"), ",") FROM booking WHERE strftime(''%m.%Y'', "DateField" ="'+sMonth+'.'+IntToStr(Year)+'"' );
if s <> '' then
begin
AStr := SplitString(s, ','); // Convert the string with days into an array AStr
SetLength(AByte, Length(AStr)); // set the length of the array AByte
// convert an array of strings into a numeric array
c := Length(AByte)-1;
for i := 0 to c do
if ValidInt(AStr[i]) then AByte[i] := StrToInt(AStr[i]) else AByte[i] := 0;
TdbMonthCalendar(Sender).BoldDays(AByte, MonthBoldInfo); // pass an array of days to the component that you want to select
end;
end;