为什么在我输入"only"后,我的文本框TextChanged事件被触发?我的文本框中有一个字符? [英] Why my textbox TextChanged event gets fired after I enter "only" one character in my text box?

查看:91
本文介绍了为什么在我输入"only"后,我的文本框TextChanged事件被触发?我的文本框中有一个字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void NameVal_TextChanged(object sender, EventArgs e)
    {
        String text = NameVal.Text;

    }

输入我名字的第一个字母后,该程序就会执行.如何使程序等待,直到我输入完该字段的整个字符串(例如Name(姓名):James).

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.

推荐答案

如果您想确定用户何时完成输入,则可以捕获请假事件-当焦点丢失在该文本框上时会触发该事件-也就是说,用户在文本框外单击:

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;
}

这篇关于为什么在我输入"only"后,我的文本框TextChanged事件被触发?我的文本框中有一个字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆