Sign in Join
Wiki copytemporary

TCalendarDialog: what changed

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

Title: TCalendarDialog

OldNewLine
1+**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]].
2+
3+<figure>
4+<img src="component-TCalendarDialog.png" title="component-TCalendarDialog.png" />
5+<figcaption>component-TCalendarDialog.png</figcaption>
6+</figure>
7+
8+The Execute [[Method|method]] displays the calendar dialog. It returns [[True|true]] when user has selected date, [[False|false]] when user has aborted.
9+
10+## Example
11+
12+1. From the menu choose Project/New Project…
13+2. Place a TCalendarDialog widget ![](/wiki-images/5/55/Tcalendardialog.png) on your [[TForm|form]].\
14+ 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]]\
15+3. Add a [[TButton|button]] ![](/wiki-images/b/b2/Tbutton.png) in the form.
16+4. 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.
17+5. Completion code:
18+
19+``` pascal
20+uses
21+ ExtDlgs, // for the CalendarDialog
22+ Calendar; // for the DisplaySettings and FirstDayOfWeek enumerations
23+
24+procedure TForm1.Button1Click(Sender: TObject);
25+var
26+ dt: TDate;
27+begin
28+ CalendarDialog1.Date := Now;
29+ CalendarDialog1.Title := 'Select a date';
30+ CalendarDialog1.DisplaySettings := [dsShowWeekNumbers];
31+ CalendarDialog1.FirstDayOfWeek := dowMonday; // in Laz 3.99+
32+ if CalendarDialog1.Execute then
33+ begin
34+ dt := CalendarDialog1.Date;
35+ ShowMessage('The selected date is ' + FormatDateTime('yyyy-mm-dd', dt));
36+ end
37+ else
38+ ShowMessage('Today is ' + FormatDateTime('yyyy-mm-dd', dt));
39+end;
40+```
41+
42+## See also
43+
44+- [[doc:lcl/dialogs/tcalendardialog.html|TCalendarDialog doc]]
45+- [[TDBDateTimePicker]]
46+- [[TDateTimePicker]]
47+- [[TDateEdit]]
48+- [[TTimeEdit]]
49+- [[TDateTime]]
50+
51+---
52+*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