Help. ErrorProvider with Databinding not showing

  • Thread starter Thread starter aboutjav.com
  • Start date Start date
A

aboutjav.com

Hi,

I added an errorprovider to my GUI layer and databinded to my business
object

bindingSource1.DataSource = MyBusinessObject;

NameTextBox.SetDataBindings("Text", bindingSource1, "NameProperty",
true, DataSourceUpdateMode.OnPropertyChanged);

The property is the followign


public string NameProperty
{
get { return m_name; }
set
{
m_name= value;
PropertyHasChanged("NameProperty");
PropertyHasChanged("VerifyPersonName");
}
}

The
PropertyHasChanged("VerifyPersonName");

will check if the textbox.text value is null or empty.

public bool VerifyPersonName(object target, RuleArgs e)
{
if (string.IsNullOrEmpty(m_name.Trim()))
{
e.Description = "Empty Field";
return false;
}
return true;
}


When I clear the Name textbox field, i see the e.Description is
called. However, the errorprovider is not visible on the GUI.

Any help is appreciated.

Thanks
 
You need to implement IDataErrorInfo in your class, and then set the error
for the property, which will pop the notify indicator on the form.

RobinS.
GoldMail, Inc.
 
Back
Top