简体   繁体   English

C#DateTimePicker转换问题

[英]C# DateTimePicker rollover problems

I have DateTimePicker controls with a custom format to show hours/minutes as well as the date ("MM/dd/yyyy HH:mm"). 我有DateTimePicker控件,该控件具有自定义格式以显示小时/分钟以及日期(“ MM / dd / yyyy HH:mm”)。 The problem I have is that if I use the up/down arrow keys to change the values they don't roll over properly when they overflow. 我的问题是,如果使用向上/向下箭头键更改值,则它们在溢出时不会正确翻转。

ex1 initial value 03/23/2011 16:58 Select minutes, hit the up arrow once: value updates to 03/23/2011 16:59 as expected Hit up arrow a second time: value updates to 03/23/2011 16:00, not 17:00 as expected. ex1初始值03/23/2011 16:58选择分钟,按一次向上箭头:值将按预期更新为03/23/2011 16:59再次按向上箭头:值将更新为03/23/2011 16: 00,而不是预期的17:00。

ex2 initial value 03/23/2011 16:00 Select minutes, hit the down arrow once: value updates to 03/23/2011 16:59, not 15:59 as expected. ex2初始值03/23/2011 16:00选择分钟,单击一次向下箭头:值更新为03/23/2011 16:59,而不是预期的15:59。

ex3 initial value 03/23/2011 23:03 Select hours, hit the up arrow once: value updates to 03/23/2011 00:03, not 03/24/2011 00:03 as expected. ex3初始值03/23/2011 23:03选择小时,按一次向上箭头:值更新为03/23/2011 00:03,而不是预期的03/24/2011 00:03。

Edit: The reason this is problematic on what I'm doing is that I'm using the DTPs to adjust the placement of objects on a timeline, and the default rollover results in the object jumping back. 编辑:这对我正在做的事情造成问题的原因是,我正在使用DTP调整对象在时间轴上的位置,并且默认翻转会导致对象跳回。 This is aggravated by the order of the objects being fixed. 固定对象的顺序会加剧这种情况。 If two are at 16:05 and 16:59, the up arrow rollover on the 2nd would result in it changing to 16:00 which is invalid. 如果两个分别位于16:05和16:59,则2号上的向上箭头翻转将导致其更改为16:00,这是无效的。

这是DateTimePicker的预期行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM