Thank you Jeffrey and Bart for help.
Here is why you need to force data from control back to the underlying data:
Scenario 1) BindingSource is in AddNew mode and you have a DateTime picker
in your form. The datetime picker show a date value, but underlying data
will have NULL value even after EndEdit. I cannot tell user to click on
datetime picker and choose the same date value.
Scenario 2) Similar to scenario 1, but you are using a data bound drop down
combobox. ** combobox's DropDownStyle must be in DropDownList mode.
Your combobox has no item in it. You force the BindingSource to AddNew mode.
Then one items to combobox. The underlying data for combobox is still NULL!!
Essentially, When your BindingSource is in AddNew mode, and you have bound
controls that cannot show NULL values, then it involves all messes around
the world!!
Does that make any sense to you?
Max
Hi,
> Thank you Jeffrey and Bart for help.
>
[quoted text clipped - 5 lines]
> will have NULL value even after EndEdit. I cannot tell user to click on
> datetime picker and choose the same date value.
AFAIK NULL value with a DateTimePicker may irreversible suspsend
DataBinding. You should definitely set a default value for the Date fields,
you can do this by adding an eventhandler to DataTable.TableNewRow (which
will called when AddNew is called). (Or find a nullable DateTimePicker)
> Scenario 2) Similar to scenario 1, but you are using a data bound drop
> down combobox. ** combobox's DropDownStyle must be in DropDownList mode.
>
> Your combobox has no item in it. You force the BindingSource to AddNew
> mode. Then one items to combobox. The underlying data for combobox is
> still NULL!!
If you mean adding ComboBox items to an empty ComboBox after AddNew, then i
can imagine this causes problems (but i haven't tried). You could use
ComboBox.DataBindings["SelectedValue"].WriteValue() after filling the
ComboBox.
> Essentially, When your BindingSource is in AddNew mode, and you have bound
> controls that cannot show NULL values, then it involves all messes around
> the world!!
>
> Does that make any sense to you?
Sure, NULL values are a big problem with DataBinding, well mostly with the
Controls. There are 3th party or opensource Controls which can handle NULL
values better.
HTH,
Greetings
> Max
>
[quoted text clipped - 13 lines]
>>
>> Max