Why my textbox TextChanged event gets fired after I enter "only" one character in my text box?

user1298925 picture user1298925 · May 18, 2013 · Viewed 7.3k times · Source
private void NameVal_TextChanged(object sender, EventArgs e)
    {
        String text = NameVal.Text;

    }

As soon as I enter the first letter of my Name this program gets executed . How do I make the program wait until I finish entering the whole string for the field (such as Name ex: James) is entered.

Answer

Daniel Flippance picture Daniel Flippance · May 18, 2013

If you want to determine when the user has finished typing, you can catch the leave event instead - this is fired when the focus is lost on that text box - ie the user clicks outside of the textbox:

private void NameVal_Leave(object sender, EventArgs e)
{
    //Do your stuff
    String text = NameVal.Text;
}