By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,734 Members | 828 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,734 IT Pros & Developers. It's quick & easy.

DateTimePicker time field carry/borrow - still stymied!

P: n/a
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
May 1 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
May 1 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.