为什么我的文本框 TextChanged 事件在我输入“only"后被触发?我的文本框中的一个字符? [英] Why my textbox TextChanged event gets fired after I enter "only" one character in my text box?
本文介绍了为什么我的文本框 TextChanged 事件在我输入“only"后被触发?我的文本框中的一个字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void NameVal_TextChanged(object sender, EventArgs e)
{
String text = NameVal.Text;
}
只要我输入我名字的第一个字母,这个程序就会被执行.如何让程序等到我完成输入字段的整个字符串(例如 Name ex: 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.
推荐答案
如果您想确定用户何时完成输入,您可以捕获 leave 事件 - 当焦点在该文本框上丢失时触发 -即用户在文本框外点击:
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;
}
这篇关于为什么我的文本框 TextChanged 事件在我输入“only"后被触发?我的文本框中的一个字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文