Parse method never called when data binding from class property to textedit

  • Thread starter Thread starter Richard Urwin
  • Start date Start date
R

Richard Urwin

I'm using C# and having problems getting the 'Parse' EventHandler of
my binding object to be called. Interestingly, the 'Format' method is
always called however. A code snippet:

(rdDocument is a private member field of the class and has a
string-type property called 'Name')

Binding bName = new Binding("Text", rdDocument, "Name");
bName.Format += new ConvertEventHandler(teName_Format);
bName.Parse += new ConvertEventHandler(teName_Validate);
textBox1.DataBindings.Add(bName);

private void teName_Format(object sender, ConvertEventArgs e)
{
<perform formatting, OK: method always called>
}

private void teName_Validate(object sender, ConvertEventArgs e)
{
string sValue = (string) e.Value;
<perform validation, PROBLEM: method never called>
}

Can anybody tell me why it's not being called or how I can force it to
be called? Help!
Rich
 
Are you sure the data is getting commited to rdDocument.Name property
without the Parse event getting called. That would be strange indeed.

You may also try calling
teName.DataBindings["Text"].BindingManagerBase.EndCurrentEdit();
incase you are setting the text directly from code.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
 

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

Similar Threads


Back
Top