On Tue, 01 May 2007 15:18:02 -0700, Ray Mitchell
<Ra*****************@MeanOldTeacher.comwrote:
[...] the problem is that I can't tell from within that event which
direction the change was going. If there were separate change events
for Up and Down it would be easy. The only other thing I can think of
is to actually compute the coordinates of where the click occurred and
determine whether Up or Down was clicked based upon that. That seems
pretty brutal, however. Any help would be appreciated.
I don't have a good answer. I took a quick look, and my first thought
didn't pan out. That is, I was hoping that the when you show the up/down
control, an actual UpDownBase control would be added as a child control
for the DateTimePicker control. Then you could just override that
control's up and down events to accomplish what you want. Unfortunately,
even when the spinner is showing, the DateTimePicker control doesn't have
any children in its Controls collection.
Maybe there still is actually an UpDownBase control in there somewhere,
and there's a way to get at it that I'm not seeing right away.
One thing I note is that I think that the ValueChanged event is definitely
the wrong place to put this functionality. You *could* store a "previous
value", updated every time the value changes, with which you'd compare the
new value. But if you did that then any time the user changed the value
in the control explicitly by typing a new value in, you'd get the same
behavior you're trying to implement for the spinner. As a user myself, I
would find that sort of thing very annoying. For example, suppose the
control initializes to "May 1, 2007" and I type in "30" where the "1" is.
If all you're doing is watching the value change, then the month would
also change, to "April" when I may well have just wanted to change the day
of the month.
Anyway, I think the right approach is to somehow get at the actual up/down
functionality directly. But I don't know how the DateTimePicker
implements this, nor do I know how to get at it. You might do a little
exploring yourself in that area though, and maybe you'll come up with
something.
Pete