焦点离开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控件的第一部分
发布评论