StrataFrame Forum

MaintenanceFormToolStrip with dateTimePicker

http://forum.strataframe.net/Topic10929.aspx

By Tony DeSanto - 8/17/2007

I have a dateTimePicker control placed on a standard SF Maintenance Form.  The dateTimePicker control is setup to clear on null when the value is 1/1/1800.  What is happening is when I use the Maintenance forms navigator and move to a record with a null value the dateTimePicker control displays a blank field which is correct but the navigator becomes grayed out and the MaintenanceFormToolStrip only allows New, Edit or Delete to be selected.  I'm unsure of why the navigator becomes grayed out.
By Trent L. Taylor - 8/17/2007

Tony, the behaviour you are describing does not really make any sense.  I beleive you in that you are having this happen to you, but the two are unrelated.  Can you reproduce this in a quick sample?
By Tony DeSanto - 8/17/2007

Using Tutorial_WinCSharp14:

I first added a dateTimePicker to the Customer Maintenance Form.  Associate the control to the cust_Created field.  I then changed the StrataFrame database in order for the cust_Created Field to allow nulls.  Then I remapped the business objects and recompiled the application.  Null out one of the records for the cust_Created fields and then run the application.  Then try to navigate on and off of that record.

By Tony DeSanto - 8/20/2007

What happens is when I navigate to a record with a null date the dateTimePicker clears out the control correctly but the business object becomes dirty which I believe is causing the navigation controls to gray out.  Is this the correct behavior?
By Trent L. Taylor - 8/21/2007

Ahhh...yeah, that is what is happening to you.  Yes, the reason is because the EditingStateChanged event fired.  You can control the EditingStateChanged a number of different ways, but that is what happened.  This is correct in the fact that when the EditingState changes on the BO that the MaintenanceFormToolstrip will respect this.  There are several things you could do in this situation.  For example, if you set the AllowMultipleModifiedRecords property to True on the MaintenanceFormToolstrip, then the navigation will not become disabled since more than one record could be modified at the same time.  Depending upon how you have the field setup to manage the NULLs in conjunction with the bound control, the value may or may not actually update the field itself.  By default, the DateTimePicker will "clear out" the field on a NULL value but not actually change the underlying value.  That is why there is the ClearKey which when pressed will in fact set the field in the table back to NULL.
By Fabian R Silva, - - 10/8/2007

Trent L. Taylor (08/21/2007)
Ahhh...yeah, that is what is happening to you. Yes, the reason is because the EditingStateChanged event fired. You can control the EditingStateChanged a number of different ways, but that is what happened. This is correct in the fact that when the EditingState changes on the BO that the MaintenanceFormToolstrip will respect this. There are several things you could do in this situation. For example, if you set the AllowMultipleModifiedRecords property to True on the MaintenanceFormToolstrip, then the navigation will not become disabled since more than one record could be modified at the same time. Depending upon how you have the field setup to manage the NULLs in conjunction with the bound control, the value may or may not actually update the field itself. By default, the DateTimePicker will "clear out" the field on a NULL value but not actually change the underlying value. That is why there is the ClearKey which when pressed will in fact set the field in the table back to NULL.




Hello, I testing the datetimepicker control, I allow null values on the database, I open the BOM and see that do not allow nulls are the default... if I test the form with the datetimepicker a error "not valid convertion from 'DBNull' to "Date' type, then I open again the BOM and set an alternate on null (#1/1/1800#) and when I test it, when null values are found it worked (show a blank value), but when a value is found (the field not is null) the editingstate change.



How I can avoid to handle this event and only show the datetime value from the field?

thanks!
By Randy Jean - 11/13/2007

Same problem I'm having... Let me know if you found a solution. I don't want the underlying buffer to be dirty when I navigate and the get of the field behavior fires regardless of how the UI handles it.
By Trent L. Taylor - 11/13/2007

This is the purpose of the NULL settings within the BO Mapper.  Create a Return Alternate Value on NULL value and set the return value to #1/1/1800# and then rebuild the partial.  So when there is a date value that is null, the BO property will return #1/1/1800# and it will be treated as a NULL by the DateTimePicker.