DateTimePicker time field carry/borrow - still stymied!

G

Guest

Hello,

I posted this about a month ago but didn't get any response, so I thought
I'd rephrase it. I have a DateTimePicker set for Up/Down Time format
(HH:mm:ss). The problem is that when I click past 59 seconds the minutes do
not increment, and similarly for minutes affecting hours. Also, similarly
for clicking backwards from 00. I've seen this work in other applications so
it must be simple. I could use a value changed event and change everything
manually but 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.

Thanks,
Ray
 
P

Peter Duniho

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top