We use derived Form-Classes, with one base form class for our software.
On the derived forms we use DataBinding extensively to deal with our BusinessObjects, all implementing IDataErrorInfo, throwing custom error-messages on false inputs to the GUI with ErrorProviders.
I now search for a way to implement a function in the base-form-class to get all ErrorProvider-Components on a Form and set the IconAlignment for every Control on the Form to left (since right is a spacing-problem).
Any Hints welcome…
Code for Setting the IconAlignment:
private void SetErrorProviderIconAlignment(ErrorProvider errorProvider, Control control)
{
errorProvider.SetIconAlignment(control, ErrorIconAlignment.MiddleLeft);
foreach (Control subControl in control.Controls)
{
SetErrorProviderIcon(errorProvider, subControl);
}
}
We used an inherited
ErrorProvidercomponent instead which forcefully set/returned the default for the IconAlignment extended property.E.g.
Then you could easily do a search/replace for
new ErrorProvider()and replace withnew MyErrorProvider().I cannot recall exactly, but you may find that you may need to open the Form’s designer in order to get it to reserialize the value passed into
SetIconAlignmentin theform.designer.csfiles…