Difference between revisions of "TCalendarDialog/zh CN"
From Free Pascal wiki
Jump to navigationJump to searchTyphonFinger (talk | contribs) (Created page with "{{TCalendarDialog}} '''TCalendarDialog''' Image:tcalendardialog.png 就是能帮你选择日期的一个控件而已. 在 Dialogs tab 的 Component Palette. im...") |
TyphonFinger (talk | contribs) (→样例) |
||
Line 10: | Line 10: | ||
== 样例 == | == 样例 == | ||
− | # | + | # 菜单中选择 工程/新建工程… |
− | # | + | # 添加 TCalendarDialog 控件 [[image:tcalendardialog.png]] 到 [[TForm|窗体]]. <br /> 位置随意,因为此控件为不显示控件 [[runtime|run time]] 仅编辑状态可见. <br \> [[Image:Component_Palette_Dialogs.png]] <br \> 在 [[Dialogs tab]] 的 [[Component Palette|component palette]] <br /> |
# Add a [[TButton|button]] [[Image:tbutton.png]] in the form. | # Add a [[TButton|button]] [[Image:tbutton.png]] in the form. | ||
# 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. | # 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. | ||
Line 37: | Line 37: | ||
end; | end; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
== See also == | == See also == |
Revision as of 11:53, 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;
See also