views:

293

answers:

1

We use BusinessObjects, implementing IDataErrorInfo and IEditableObject. BindingLists 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?

+1  A: 

You need to set FormattingEnabled property to false to disable error-handling behaviour.

Like this:

            this.textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bindingSource1, "IntValue", false, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
Jacob Seleznev
That stops those auto generated Messages. At least a first step. The next thing will then be to catch all inputs, validate them and provide custom error messages. Thank you for that.
BeowulfOF