Sign in Join
Wiki copytemporary

TCalendarDialog/zh CN: 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) 就是能帮你选择日期的一个控件而已. 在 [[Dialogs tab]] 的 [[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
85Execute [[Method|方法]] 来显示对话框. 选择日期后返回 [[True|true]] , 未选择就返回[[False|false]] .
96
107## 样例
118
1291. 菜单中选择 工程/新建工程…
13102. 添加 TCalendarDialog 控件 ![](/wiki-images/5/55/Tcalendardialog.png) 到 [[TForm|窗体]].\
1411 位置随意,因为此控件为不显示控件 [[runtime|run time]] 仅编辑状态可见. \<br \\\> ![](/wiki-images/7/72/Component_Palette_Dialogs.png) \<br \\\> 在 [[Dialogs tab]] 的 [[Component Palette|component palette]]\
15123. 添加 [[TButton|button]] ![](/wiki-images/b/b2/Tbutton.png) 到窗体.
16134. [[IDE Window: Object Inspector|对象查看器]] 中查看按钮的事件,在OnClick事件右侧点击 ... 按钮,添加对应的代码。
17145. 完成代码:
1815
1916``` pascal
2017procedure TForm1.Button1Click(Sender: TObject);
2118var
2219 dt:tdatetime;
2320 calendarSettings:TDisplaySettings;
2421begin
2522 dt:= now;
2623 CalendarDialog1.Date := dt;
2724 calendarSettings:= [dsShowWeekNumbers,dsStartMonday];
2825 CalendarDialog1.Title:='Select a date';
2926 CalendarDialog1.DisplaySettings:= calendarSettings;
3027 if CalendarDialog1.Execute then
3128 begin
3229 dt:= CalendarDialog1.Date;
3330 ShowMessage( 'The selected date is '+FormatDateTime( 'yyyy-mm-dd',dt ));
3431 end
3532 else
3633 ShowMessage( 'Today is '+FormatDateTime( 'yyyy-mm-dd',dt ));
3734end;
3835```
3936
4037## 参考资料
4138
4239- [[doc:lcl/dialogs/tcalendardialog.html|TCalendarDialog doc]]
4340- [[TDBDateTimePicker]]
4441- [[TDateTimePicker]]
4542- [[TDateEdit]]
4643- [[TTimeEdit]]
4744- [[TDateTime]]
4845
4946---
5047*From the Free Pascal wiki, page "TCalendarDialog/zh CN", as it stood on 2020-05-03 after a change by TyphonFinger, 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