DataBinding and ErrorProvider - How to provide custom error messages?
Posted
by BeowulfOF
on Stack Overflow
See other posts from Stack Overflow
or by BeowulfOF
Published on 2010-04-01T09:36:37Z
Indexed on
2010/04/01
9:43 UTC
Read the original article
Hit count: 311
We use BusinessObjects, implementing IDataErrorInfo
and IEditableObject
. BindingList
s with those Objects are added to BindingSources, those are used to bind UserControls and DataGrids on the forms (WinForms). The BindingSource
is additionally set as DataSource to the ErrorProvider
of the form.
We do use currently TextBoxes for Properties of Type int and short. They are validated inside the BusinessObjects with custom validation, like min/max values, etc. That works fine, since error message form our custom validations show up nicely next to the TextBox.
However, if the input is greater than the value of an int (e.g. "9999999999") the BindingSource doesn't even try to enter that Value into the BusinesObject but instead gives the errormessage to the errorprovider like "The value for Int32 was too big.". We do not want to bother our users with "Int32" but want a custom errormessage for that.
It is nice, that the BindingSource does provide this feature, but is it possible to provide custom error messages for this?
© Stack Overflow or respective owner