I have an UltraComboEditor that is databound to a reference property on a single object. I have the Nullable property set to true on the UltraComboEditor. When I clear the text of the UltraComboEditor, it tries to set the underlying property value to DBNull instead of null. I thus get the ArgumentException: "Object of type 'System.DBNull' cannot be converted to type 'YNAB.Data.SubCategory'.". Is there a way to force the UltraComboEditor to use null instead of DBNull? If not, is there a way that I can tell the underlying code how to convert from DBNull to null? I tried making a custom TypeConverter, and all tried making an implicit conversion operator, and niether seem to work, although I certainly could be missing something obvious.
Many thanks for any help you can offer,
Taylor
Hi Taylor,
I think what you can do is use the Binding object. This is the object that is returned to you when you call DataBindings.Add on the control. The proprety you are looking for is DataSourceNullValue.
What if you are not binding the control? I have the same issue with the UltraNumericEditor but I am simply setting and getting the ctl.Value when I need it, no binding involved. I would much rather cast numEditor.Value to a nullable decimal than check if it is DBNull.Value then set accordingly.
Anything I can do about this? Thanks.