This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello- I am using Sqlite3 with Lightspeed 2.2 Pro (upgraded from 2.1) in VS2008, .NET 2.0. I have an entity named Person with a column named Dob which is a DateTime. There are no validation properties on this DOB column. My data binding on my Form is this.dateTimePicker1.DataBindings.Add("Value", m_Person, Person.DobField); My issue is that when I bind this column to a WinForms DateTimePicker, the value is never updated to the entity. Further, any entry seems to be 'rejected'. By 'rejected' I mean that if I change the date (typing or selecting from the picker), then leave the control, the value in the control is reset back to DateTime.Now. In other words, I cannot seem to change the value of the Dob column using data binding. Changing it programmatically seems to work fine. The other columns on this entity bound to regular text boxes seem to work fine so I don't believe there is any issue with my entity instance. Any suggestions or comments would be most appreciated. Regards |
|
|
To clarify, I wrote "the value in the control is reset back to DateTime.Now." That really should read "the value in the control is reset back to the DateTime of its original value (from the database) or to DateTime.New (its default value for new rows). My apologies for being unclear. Regards, |
|
|
Hello Lionel, I've tried to reproduce this problem but with no luck. I am testing using VS2008 SP1, but targeting .NET 2.0. I am seeing the entity DateTime property being updated correctly (though I did notice it doesn't appear to update until the control loses focus), and I'm not seeing the reset behaviour you describe. Would it be possible for you to put together a small project that reproduces the problem and post it here (you can attach a zip file via the Options tab)? Thanks! |
|
|
Hello Ivan- I've attached a complete folder of a solution that exhibits what I am seeing. I do not see this behavior with any non-DateTimePicker controls. That said, I am new to Mindscape technologies and assume I am munging something :) What I do on the attachment is select a different date from the picker, then click the button. In my test, the value in the datetimepicker (and the underlying Person entity) is reset back to the default set in the Load of the form. Thank you for any feedback and I appreciate your time very much! Regards,
|
|
|
This appears to be down to a rather odd interaction between the DateTimePicker and the Nullable<DateTime> type. I can't explain why it happens, but it does appear to fix itself if you use another overload of the constructor and pass formattingEnabled = true: this.dateTimePicker1.DataBindings.Add("Value", m_Person, Person.DobField, true); (It also works fine if the DateTime is non-nullable, which is why I failed to reproduce it.) |
|
|
Ivan- Thank you for your time and uncovering that oddity - my bound DateTimePicker/Entity is working fine now! I appreciate your time researching. Regards,
|
|