Matthias

Hello,

the BindingCompleteState that comes with a BindingComplete event has three possible values: Success, Exception, and DataError. The former two are quite clear. However, I have no clue under which circumstances the latter - DataError - could occur. If there is any chance to make use of it in the context of validation and data binding, particularly to custom object datasources, I would be very happy to learn how.

Regards,

Matthias



Re: Windows Forms Data Controls and Databinding how to trigger BindingCompleteState.DataError

Zhi-Xin Ye - MSFT

The BindingCompleteState.DataError occurs when being able to push the value into the property but the value failed validation.




Re: Windows Forms Data Controls and Databinding how to trigger BindingCompleteState.DataError

Matthias

Thanks for the reply!

However, this reads for me somehow like "... occurs when there is Christmas in July". How can I set up a binding to a datasource (object datasource, if possible by any means) so that setting the property in the model works, but a validation error is reported I mean - Parse can fail only with an exception, the same holds for a TypeConverter, and if I set Cancel=true in the Validating event BindingComplete isn't even called.

Let's have for example a Person object with a property "Age" of type int. How could I bind a text box to Person.Age so that I get BindingCompleteState.DataError whenever I enter a negative integer into the text box There is no problem pushing a negative integer into the Age property, but I don't see where I could implement a validation so that a DataError would be reported.