读书人

怎么实现 向一个TEXT框输入内容等输

发布时间: 2011-12-18 22:54:38 作者: rapoo

如何实现 向一个TEXT框输入内容,等输入完毕后自动判断其内容正确性的事件?
如何实现 向一个TEXT框输入内容,等输入完毕后自动判断其内容正确性的事件?
关键是这个事件要写在那里?
我要实现的就是当用户输入完毕后就自动搜索出与输入相关的资料。
比如输入用户名,就自动搜索出于此用户相关的性别,年龄,住址等等

在TEXTBOX的那里写这个事件啊? 或者要用那个控件实现?

[解决办法]
Validating 事件
[解决办法]
Validating 和 Validated
两个时间,专门用来做这个事情

C# code
private void textBox1_Validating(object sender,                  System.ComponentModel.CancelEventArgs e){   string errorMsg;   if(!ValidEmailAddress(textBox1.Text, out errorMsg))   {      // Cancel the event and select the text to be corrected by the user.      e.Cancel = true;      textBox1.Select(0, textBox1.Text.Length);      // Set the ErrorProvider error with the text to display.       this.errorProvider1.SetError(textBox1, errorMsg);   }} 

读书人网 >C#

热点推荐