C# - 时间格式的 DateTimePicker 在按 Tab 键切换到下一个框时不关注小时值
我在很多网站上都没有找到类似的内容,所以希望大家能帮忙。
我有一个用于时间表系统的数据网格,因此时间输入/输出等的特定单元格已设置为dateTimePickers
(使用覆盖日历类)。
如果用户输入 08:00
并按 Tab 键跳至下一个 dtp,则焦点默认为小时。但是,如果用户输入 08:30
(他们输入了小时,然后按向右箭头键移至分钟),然后按 Tab,则下一个 dtp 的焦点仍位于分钟。
有没有办法在代码中设置焦点或将每个 dtp 默认为小时?
I haven't found anything similar on numerous websites, so I hope you guys can help.
I have a datagrid for a timesheet system, so the specific cells for the time in/out etc have been set to dateTimePickers
(using an override calandar class).
If the user puts in 08:00
and tabs to the next dtp, the focus is defaulted to the hour. However, if the user puts in 08:30
(they have put the hour in, then pressed the right arrow key to move to minutes), and then presses tab, the focus on the next dtp remains on minutes.
Is there a way to set the focus in the code or something to default to hour on each dtp?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
扩展我的评论,我没有看到 DateTimePicker 以任何方式公开当前选择,也不允许为其保存的文本指定任何 SelectionLength 。所以我认为这是不可能的。
根据不同的想法,有一个丑陋的黑客(不推荐),我相信它并不比你最后的情况更好。
在这里找到,您可以尝试参加任一活动
Expanding on my comment i don't see in any way DateTimePicker exposing the current selection nor does it allow specifying any SelectionLength for the text it holds. So i don't think this can be possible.
On a different thought there is an ugly hack (not recommended) which i believe is no better than the situation you have at end.
Found here you may try in either of the events