我无法从 C++ 构建器 ide 中的 TDateTimePicker 获取日期时间。我正在格式化它以显示日期和时间,但它只显示日期,因为我认为它的Kind
属性设置为dtkDate
. 是否可以从此组件获取日期和时间?
ShowMessage(deARV->DateTime.FormatString("dd.MM.yyyy HH:mm"));
我无法从 C++ 构建器 ide 中的 TDateTimePicker 获取日期时间。我正在格式化它以显示日期和时间,但它只显示日期,因为我认为它的Kind
属性设置为dtkDate
. 是否可以从此组件获取日期和时间?
ShowMessage(deARV->DateTime.FormatString("dd.MM.yyyy HH:mm"));
TDateTimePicker
其Kind
属性设置为的 AdtkDate
没有与之关联的时间。如果您同时需要日期和时间,则必须使用两个单独的TDateTimePicker
控件,一个设置为dtkDate
,另一个设置为dtkTime
。然后,您可以在需要时将它们的两个值组合在一起,例如:
TDateTime dtDateTime = deARVDate->Date + deARVTime->Time;
ShowMessage(dtDateTime.FormatString("dd.MM.yyyy HH:mm"));
我已经看到,有时这会导致值的未使用部分出现垃圾值TDateTime
,所以我更喜欢使用它:
TDateTime dtDateTime;
ReplaceDate(dtDateTime, deARVDate->Date);
ReplaceTime(dtDateTime, deARVTime->Time);
ShowMessage(dtDateTime.FormatString("dd.MM.yyyy HH:mm"));
或这个:
TDateTime dtDateTime = DateOf(deARVDate->Date) + TimeOf(deARVTime->Time);
ShowMessage(dtDateTime.FormatString("dd.MM.yyyy HH:mm"));