Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 979
user1298925 Avatar asked May 17 '13 23:05

user1298925


1 Answers

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;
}
like image 105
Daniel Flippance Avatar answered Jan 01 '23 14:01

Daniel Flippance