Validating event firing twice when using UserControl

M

maksim.yevstratov

Hi,

I have a UserControl with a TextBox in it. TextBox has Validating event

handler that can cancel the validation. If I place two UserControls
like this on a form then Validating event will be firing twice. To
demostrate this I put the following code inside the UserControl.


private int count = 0;
private void textBox1_Validating(object sender, CancelEventArgs

e)
{
e.Cancel = true;
textBox1.Text = (count++).ToString();
}


I can see then the couter growing by 2 every time I try to change focus

from one user control to another.

The behavior is the same in VS.NET2003 and VS2005.

Can anybody explain why it's happening and what could be a fix or
workaround?


Thanks
 
M

maks

I figured out that it happens only when using a mouse. When using
keyboard Validating event firing only once as it supposed to do. Looks
like a bug for me...
 

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