DateTimePicker valueChanged is too slow

Adagio

Well-known member
Joined
Dec 12, 2005
Messages
162
Programming Experience
Beginner
In my DTP when the user presses Enter I have set it to call some code that uses the DTP value, but unfortunately the DTP updates it's value too slow (the code is called before the value has changed). This causes the code to use the old value instead of the new value

If I make it open a msgbox inside the valueChanged code, then the value changes before the other code is called, but that's not really an option


Is there a way to make sure that the value is set (if there has been made a change) before the other code is called?
 
There's a reason it "grabs" the "wrong" date.... built into the DTP is a delay of roughly one second (might be a little less)... between the last keystroke and the Changed event fires. Why? It gives the user the opportunity to enter a full complete (And hopefully correct date)... otherwise you would get the change event firing for incomplete dates. So it uses a built-in delay, and fires off the change event when that delay expires from the last keystroke - UNLEss, the user uses the dorp down and picks a date, then the change fires immediately, or focus leaves the DTP.

How we solved this problem. Users have to click a refresh button, or some other button to perform further action with the date. You'ld be amazed at how quickly people adapt to this.

You could add a button to the form next to the DTP that does the refresh, and if the user is in the DTP when they hit enter, sendfocus to the command button (thereby losing focus on the DTP), and call the .Click (or is it .DoClick? Something like that) to fire off the processing. At that point you could then send focus back to the DTP,and the user probably wouldn't know the difference.

-tg
 
You could add a button to the form next to the DTP that does the refresh, and if the user is in the DTP when they hit enter, sendfocus to the command button (thereby losing focus on the DTP), and call the .Click (or is it .DoClick? Something like that) to fire off the processing. At that point you could then send focus back to the DTP,and the user probably wouldn't know the difference.


That sounds like a good idea, I'll try that out to see if it works
 
I'll see if I can explain it a different way, because it seems like you have no idea what I'm talking about

I knew what you were talking about.. You just never answered my question as to why you need the DTP to operate like this.

When I design a form, it might have 5 DTP on it, and they are used in a database query that runs when the user clicks the "Run Query" button.

Hence, because the action that instigates the database query comes after the values have been set, it isnt really an issue.

What you never actually explained, was why you ran a database query so instantly
 
Back
Top