Sign in Join
Wiki copytemporary

TCalendarDialog: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11**TCalendarDialog** ![](/wiki-images/5/55/Tcalendardialog.png) is a dialog that aids in selecting a date from a calendar. It can be found on the [[Dialogs tab]] of the [[Component Palette]].
22
3-<figure>
4-<img src="component-TCalendarDialog.png" title="component-TCalendarDialog.png" />
5-<figcaption>component-TCalendarDialog.png</figcaption>
6-</figure>
3+![](/wiki-images/e/e5/Component-TCalendarDialog.png)
74
85The Execute [[Method|method]] displays the calendar dialog. It returns [[True|true]] when user has selected date, [[False|false]] when user has aborted.
96
107## Example
118
1291. From the menu choose Project/New Project…
13102. Place a TCalendarDialog widget ![](/wiki-images/5/55/Tcalendardialog.png) on your [[TForm|form]].\
1411 It can be placed anywhere as it is not visible during program [[runtime|run time]] but only during design time. \<br \\\> ![](/wiki-images/7/72/Component_Palette_Dialogs.png) \<br \\\> It is located on the [[Dialogs tab]] of the [[Component Palette|component palette]]\
15123. Add a [[TButton|button]] ![](/wiki-images/b/b2/Tbutton.png) in the form.
16134. The [[IDE Window: Object Inspector|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.
17145. Completion code:
1815
1916``` pascal
2017uses
2118 ExtDlgs, // for the CalendarDialog
2219 Calendar; // for the DisplaySettings and FirstDayOfWeek enumerations
2320
2421procedure TForm1.Button1Click(Sender: TObject);
2522var
2623 dt: TDate;
2724begin
2825 CalendarDialog1.Date := Now;
2926 CalendarDialog1.Title := 'Select a date';
3027 CalendarDialog1.DisplaySettings := [dsShowWeekNumbers];
3128 CalendarDialog1.FirstDayOfWeek := dowMonday; // in Laz 3.99+
3229 if CalendarDialog1.Execute then
3330 begin
3431 dt := CalendarDialog1.Date;
3532 ShowMessage('The selected date is ' + FormatDateTime('yyyy-mm-dd', dt));
3633 end
3734 else
3835 ShowMessage('Today is ' + FormatDateTime('yyyy-mm-dd', dt));
3936end;
4037```
4138
4239## See also
4340
4441- [[doc:lcl/dialogs/tcalendardialog.html|TCalendarDialog doc]]
4542- [[TDBDateTimePicker]]
4643- [[TDateTimePicker]]
4744- [[TDateEdit]]
4845- [[TTimeEdit]]
4946- [[TDateTime]]
5047
5148---
5249*From the Free Pascal wiki, page "TCalendarDialog", as it stood on 2023-09-09 after a change by Wp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history