views:

173

answers:

1

Good Afternoon!

Has anybody else noticed a change in the default behavior of the "next" and "previous" month arrows in the standard WinForms DateTimePicker control? I have users running on both Windows Server 2003 and Windows Server 2008 R2, and they are reporting that on 2008 (and Vista/Win7), clicking the right or left arrows on the drop-down Calendar now selects the first day of the month rather than retaining the same day like 2003 (and XP) does.

I have checked this out (I have a Win7 machine) and I have confirmed this behavior. I would prefer that the behavior remain consistent whenever possible. Does anybody know what causes this and if there is a way to get around this? Is there a way to trap the arrow-click event and force the resulting date to retain the original day rather than be reset to the first of the month?

I thought about seeing if there was a way to hit-test the control on a MouseUp event and determine if the arrow buttons were clicked, and then override the month value being set, but I'm not sure if that is even possible. Can anybody provide some wisdom or insight? Thanks!

+1  A: 

DateTimePicker is a native Windows control, the .NET class is wrapper for it. Yes, several look-and-feel changes in that native control since Vista. You should not fix behavior, the user will perceive your control to have non-standard behavior since it acts differently from all other ones shown by different programs that run on that operating system.

Hans Passant
True enough, but my user base is a small one (just the company I work for), and they are the ones who brought it to my attention. I do use the DTP in other applications, and the general idea was that if there was a fix or a hack that could do the trick, then I could either write an extension for the control or just apply the code to everywhere I use the control. If, of course, there isn't a fix (and I spent a fair amount of time yesterday trying a lot of stuff that didn't work), then they'll just have to understand (even if I don't (-: ). Thanks, Hans. That does make good sense.
Mike Loux
Yes, there's no good way to fix this. Short from the difficulty of sub-classing the month calendar, the MCN_SELCHANGE message doesn't let you discover exactly how the selected date was changed. Everybody will stop complaining when they switch to Win7.
Hans Passant
I have also noticed that the default behavior of the ComboBox has changed as well, in drop-down mode. Used to be you could select the item you want with a text search or arrow keys and then tab out of the control while still dropped-down and have the value remain what you had navigated to. Now if you don't hit Enter to accept the value, it selects the next one down when you tab out. Go figure...
Mike Loux