K
Kevin
I have put a VS2005 sample project up here:
http://www.kevinandkiran.com/CSharpApplication.zip (its only 50k)
Basically I have a class that contains a date property, which is
initialised to 1/1/1970. I create a project datasource from this and
then drag my class onto my form which binds my property to a
datetimepicker.
However when I set the bindingsource to be an instance of my class at
runtime I get the following exception:
System.ArgumentOutOfRangeException: Value of '01/01/0001 00:00:00' is
not valid for 'Value'. 'Value' should be between 'MinDate' and
'MaxDate'.
Parameter name: Value
at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object
component, Object value)
at System.Windows.Forms.Binding.SetPropValue(Object value)
at System.Windows.Forms.Binding.PushData(Boolean force)
If I bind to the text property of the datetimepicker it works. But
this seems strange, why wont it bind to the Value property of the
datetimepicker? I have seen plenty of examples of this when binding
to a database table with DBNull values, but not to a business object
like mine.
Interestingly if I put a breakpoint on the get of the property it
doesnt stop until after the exception has been thrown.
Thanks in advance
Kevin
http://www.kevinandkiran.com/CSharpApplication.zip (its only 50k)
Basically I have a class that contains a date property, which is
initialised to 1/1/1970. I create a project datasource from this and
then drag my class onto my form which binds my property to a
datetimepicker.
However when I set the bindingsource to be an instance of my class at
runtime I get the following exception:
System.ArgumentOutOfRangeException: Value of '01/01/0001 00:00:00' is
not valid for 'Value'. 'Value' should be between 'MinDate' and
'MaxDate'.
Parameter name: Value
at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object
component, Object value)
at System.Windows.Forms.Binding.SetPropValue(Object value)
at System.Windows.Forms.Binding.PushData(Boolean force)
If I bind to the text property of the datetimepicker it works. But
this seems strange, why wont it bind to the Value property of the
datetimepicker? I have seen plenty of examples of this when binding
to a database table with DBNull values, but not to a business object
like mine.
Interestingly if I put a breakpoint on the get of the property it
doesnt stop until after the exception has been thrown.
Thanks in advance
Kevin