Date Selection
TTMSFNCCalendar supports single and multi-date selection, keyboard navigation, and programmatic range selection. The same API applies to TTMSFNCDatePicker, which displays the calendar in a dropdown.
Selecting dates
// --- Single date selection ---
TMSFNCCalendar1.SelectADate(Now + 2); // select one date, deselects all others
// --- Multi-date selection (requires MultiSelect) ---
TMSFNCCalendar1.Interaction.MultiSelect := True;
TMSFNCCalendar1.SelectDate(Now - 3); // add a date to the selection
TMSFNCCalendar1.SelectDate(EncodeDate(2025, 12, 25));
// Range selection: select all dates from AStartDate to AEndDate (clears prior selection)
TMSFNCCalendar1.SelectMultiDates(Now - 10, Now + 5);
// --- Reading selected dates ---
var
d: TDate;
begin
d := TMSFNCCalendar1.SelectedDate; // last / only selected date
if TMSFNCCalendar1.SelectedDates.Count > 0 then
d := TMSFNCCalendar1.SelectedDates.Items[0];
end;
// --- Deselecting ---
TMSFNCCalendar1.SelectedDates.UnselectAll;
TMSFNCCalendar1.SelectedDates.UnselectDate(Now);
// --- Date limits ---
TMSFNCCalendar1.MinDate := EncodeDate(2024, 1, 1);
TMSFNCCalendar1.MaxDate := EncodeDate(2026, 12, 31);
// --- Navigate the calendar view ---
TMSFNCCalendar1.Date := EncodeDate(2025, 6, 1); // jump to June 2025
TMSFNCCalendar1.Month := 12;
TMSFNCCalendar1.Year := 2025;
// React to selection
procedure TForm1.TMSFNCCalendar1SelectDate(Sender: TObject; ADate: TDate);
begin
ShowMessage(DateToStr(ADate) + ' selected');
end;
SelectADate — replace selection
TMSFNCCalendar1.SelectADate(Now + 2);
Selects one date and deselects everything else. Also moves the focused date to the selected date.
SelectDate — add to selection
TMSFNCCalendar1.Interaction.MultiSelect := True;
TMSFNCCalendar1.SelectDate(Now - 3);
TMSFNCCalendar1.SelectDate(EncodeDate(2025, 12, 25));
Keeps existing selected dates and adds the new one. Requires MultiSelect = True for more than one date.
SelectMultiDates — range selection
TMSFNCCalendar1.SelectMultiDates(Now - 10, Now + 5);
Selects all dates from AStartDate to AEndDate and clears any previous selection.
Reading selected dates
var d: TDate;
begin
d := TMSFNCCalendar1.SelectedDate; // last/only selected date
if TMSFNCCalendar1.SelectedDates.Count > 0 then
d := TMSFNCCalendar1.SelectedDates.Items[0];
end;
Deselecting dates
TMSFNCCalendar1.SelectedDates.UnselectAll; // clear all
TMSFNCCalendar1.SelectedDates.UnselectDate(Now); // clear one date
Date limits
TMSFNCCalendar1.MinDate := EncodeDate(2024, 1, 1);
TMSFNCCalendar1.MaxDate := EncodeDate(2026, 12, 31);
Dates outside the min/max range are disabled and cannot be selected.
Interaction options
Set on TTMSFNCCalendar.Interaction:
| Property | Description |
|---|---|
MultiSelect |
Enable selecting more than one date. |
KeyboardSupport |
Allow keyboard navigation of the focused date. |
ReadOnlyMode |
Disable all user date selection. |
Events
| Event | Description |
|---|---|
OnBeforeSelectDate |
Fires before a date is selected. |
OnSelectDate |
Fires after a date is selected. |
OnSelectMultiDate |
Fires during a SelectMultiDates range operation. |