Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateTimePicker control not returning correct value when tabbing off th

Status
Not open for further replies.

aprobe

Programmer
Dec 4, 2003
36
0
0
NZ
I'm using VS2008 and have an unbound DateTimePicker control on a windows form.
It's working correctly if I select a date from the calendar and then press tab to exit.
I have a "Validated" event and the Text property (and value property) show the value as displayed.
However, If I go back and manually change the day from the 5th to the 6th for example and then tab out of the control the new value is not always being picked up in the "Validated" event.
Sometimes it is correct, sometimes not, more than half the time not!
I have put breakpoints in at other points (i.e. on entering another field) and it appears to be correct then.
It's almost as if there is a delay in recognising the change.
I've even resorted to adding an Application.DoEvents() in the validated event prior to checking the value but that has not helped.
Please note that the problem ONLY happens when manually changing the date (not from the calendar) and TABBING off the control. If I manually change the value and then use the mouse to navigate to another field it always works correctly.
I really can't beleive I'm having such hassle from a simple thing, I've spent hours trying to find a cause or a particular pattern without success.
I would be grateful for any help in this matter.
 
I've added a LostFocus Event to the DateTimePicker and checked the value there and it is now working correctly.

Why it works there and not on the Validated event I cannot understand!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top