Using the DateTimePicker

ahbenshaut

Well-known member
Joined
Oct 29, 2004
Messages
62
Location
Alaska
Programming Experience
5-10
I have noticed an odd thing happening with the datetimepicker. I have a form that gets values from SQL. When the form is loaded, a value is assigned to the datetimepicker and the checkbox appears checked. However, if the user doesn't actually open the datetimepicker and select a date ( it could even be the same date) the DateTimePicker.Checked returns a False. Why is this happening? And is there some sort of workaround? Another way of checking the value???

Please help, this is really annoying...:)
 
The DateTimePicker is a little idiosyncratic (read: buggy) in .NET 1.1. I think they've cleaned it up a bit in .NET 2.0. I have encountered this issue myself and I believe I ended up explicitly checking and unchecking the control in code, which synchronised the display and underlying property.
 
hmm..OK, something else..If I assign the DateTimePicker a value thru code, SQL Server, and then add the following: DateTimePicker.Checked=False, it still shows the DateTimePicker as checked...What am I doing wrong?
 
Like I said, it is a bit idiosyncratic and I'm afraid I can't remember what all the issues were and their workarounds. Check the MS Knowledge Base, which you can search from MSDN, to see if it mentions anything. If not, experiment a little. I know in situations like your's I would have done something like explicitly set the date to something, set it back again and then set the Checked value. I can't guarantee that this will work but it's the sort of thing you need to try.
 
Back
Top