将焦点返回到Delphi TDateTimePicker控件的第一部分

编程入门 行业动态 更新时间:2024-10-08 08:32:39
本文介绍了将焦点返回到Delphi TDateTimePicker控件的第一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

焦点离开TDateTimerPicker控件,然后在稍后返回时,该控件会记住哪个部分(日,月或年)具有焦点.焦点返回到该部分.

After the focus leaves a TDateTimerPicker control and then at a later time returns to it, the control remembers which part (day, month or year) had the focus. Focus is returned to that part.

如何将焦点强制回到控件的第一个?

How can I force the focus back to the first per of the control?

推荐答案

要强制控件忘记哪个部分具有焦点,可以更改DateFormat,然后再次将其更改.因此,如果将其设置为dfShort,则将其设置为dfLong,然后再返回到dfShort.

To force the control to forget which part had the focus you can change the DateFormat and then change it back again. So if it is set to dfShort set it to dfLong and then back to dfShort.

诀窍不是在通过OnEnter事件返回焦点之后执行此操作,而是在返回焦点之前执行此操作.

The trick is not to do this after the focus returns via the OnEnter event, but to do it before the focus is returned.

所以最好的选择是在OnExit事件中.

So the best place to do this is in the OnExit event.

procedure TForm1.DateTimePicker1Exit(Sender: TObject); begin DateTimePicker1.DateFormat := dfLong; DateTimePicker1.DateFormat := dfShort; end;

更多推荐

将焦点返回到Delphi TDateTimePicker控件的第一部分

本文发布于:2023-10-31 06:54:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545349.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   第一部分   焦点   TDateTimePicker   Delphi

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!