简体   繁体   中英

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"). 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.

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.

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.

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. 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.

这是DateTimePicker的预期行为。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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