Help. ErrorProvider with Databinding not showing

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
 
R

RobinS

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top