Difference between revisions of "TCalendarDialog/zh CN"
From Free Pascal wiki
Jump to navigationJump to searchTyphonFinger (talk | contribs) (→样例) |
TyphonFinger (talk | contribs) |
||
Line 38: | Line 38: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | == | + | == 参考资料 == |
* [[doc:lcl/dialogs/tcalendardialog.html|TCalendarDialog doc]] | * [[doc:lcl/dialogs/tcalendardialog.html|TCalendarDialog doc]] | ||
* [[TDBDateTimePicker]] | * [[TDBDateTimePicker]] |
Revision as of 13:32, 3 May 2020
│
English (en) │
suomi (fi) │
français (fr) │
русский (ru) │
中文(中国大陆) (zh_CN) │
TCalendarDialog 就是能帮你选择日期的一个控件而已. 在 Dialogs tab 的 Component Palette.
Execute 方法 来显示对话框. 选择日期后返回 true , 未选择就返回false .
样例
- 菜单中选择 工程/新建工程…
- 添加 TCalendarDialog 控件 到 窗体.
位置随意,因为此控件为不显示控件 run time 仅编辑状态可见.
在 Dialogs tab 的 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;
参考资料