From Free Pascal wikiJump to navigationJump to search
English (en) │
suomi (fi) │
français (fr) │
русский (ru) │
中文（中国大陆） (zh_CN) │
TCalendarDialog is a dialog that aids in selecting a date from a calendar. It can be found on the Dialogs tab of the Component Palette.
The Execute method displays the calendar dialog. It returns true when user has selected date, false when user has aborted.
- From the menu choose Project/New Project…
- Place a TCalendarDialog widget on your form.
It can be placed anywhere as it is not visible during program run time but only during design time.
It is located on the Dialogs tab of the component palette
- Add a button in the form.
- The Object Inspector will display the properties of the object Button1. Click on the Events tab on the Object Inspector. Select the box to the right of OnClick: a smaller box with three dots (... ellipsis) appears. Click on this, you are taken automatically into the Source Editor and your cursor will be placed in a piece of code starting.
- Completion code:
procedure TForm1.Button1Click(Sender: TObject); var dt:tdatetime; calendarSettings:TDisplaySettings; begin dt:= now; CalendarDialog1.Date := dt; calendarSettings:= [dsShowWeekNumbers,dsStartMonday]; CalendarDialog1.Title:='Select a date'; CalendarDialog1.DisplaySettings:= calendarSettings; if CalendarDialog1.Execute then begin dt:= CalendarDialog1.Date; ShowMessage( 'The selected date is '+FormatDateTime( 'yyyy-mm-dd',dt )); end else ShowMessage( 'Today is '+FormatDateTime( 'yyyy-mm-dd',dt )); end;