views:

245

answers:

4

I am creating a windows form in C#,

I have phone and email fields that I want to validate when the user leaves the fields, when I double click the textbox in visual studio, it writes a textchanged event, I don't want to call the validate method until the user is done entering the full entry.

Is there a way to do this similar to OnBlur in Javascript?

So Ihave tried MouseLeave,Off Focus, and they all act like TextChanged,

I dont want to raise my validation event until the user is done typing, not after every keystroke.

Does anybody know how to do this,

This is for a desktop app, not an asp.net project.

A: 

OnLostFocus, maybe?

Anton Gogolev
A: 

There's an OnLostFocus event for controls. You should be able to use that.

David Hedlund
+5  A: 

The Validating event was designed to do this. Set e.Cancel = true if you're not happy with the input. The ErrorProvider component is ideal to provide visual feedback.

Hans Passant
A: 

try the "Leave" event.

Scott Vercuski
Thanks, but it responds the same as textChanged.
Alex
I was changing _textChanged to Leave, I learned about the the lightning bolt in the properties explorer. I had only worked with a text editor for my PHP and Javascript classes. I am really starting to like Visual Studio.
Alex
Excellent ! Visual Studio is a pretty powerful editor.
Scott Vercuski