TCalendarDialog/zh CN
From Free Pascal wiki
Jump to navigationJump to searchThe printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
│
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 - 添加 button 到窗体.
- 对象查看器 中查看按钮的事件,在OnClick事件右侧点击 ... 按钮,添加对应的代码。
- 完成代码:
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;
参考资料