文字改变了事件 [英] text changed events

查看:75
本文介绍了文字改变了事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生



如何在使用窗口应用程序中使用textchanged事件

dear sir

How to can textchanged event in use window application

推荐答案

在VS中查找在设计模式下的形式。突出显示您关注的TextBox。

查看属性窗格,切换到事件模式 - 这是小闪电按钮。

向下滚动到TextChanged事件并双击它。

您的表单代码将显示一个新的事件处理程序。



你现在可以做什么您需要更改文本框文本。
In VS look at your form in design mode. Highlight the TextBox you are concerned with.
Look at the Properties pane, and switch to "events" mode - it's the little lightning bolt button.
Scroll down to the TextChanged event and double click it.
The code for your form will be displayed with a new event handler created.

You can now do what you need to when the textbox text is changed.


添加TextChanged:



Add TextChanged :

// This is the manual way
// Type 'this.TextChanged += ' into your form's constructor.
// Then press TAB twice, and you will have a new event handler.
this.TextChanged += new EventHandler(Form1_TextChanged);





在TextChanged中使用Text属性的代码片段





Code Fragment that uses Text property in TextChanged

void textBox1_TextChanged(object sender, EventArgs e)
{
    PopulateGrid(textBox1.Text);
}

void PopulateGrid(string queryStr)
{
    dataGridView1.DataSource = _journal.GetSearchResults(queryStr);
    SetStatus(dataGridView1.Rows.Count); // Change status bar (not shown)
}

< br $>




欲了解更多信息,请查看: http:/ /www.dotnetperls.com/textchanged [ ^ ]



我希望这会对你有所帮助。




For more info check this :http://www.dotnetperls.com/textchanged[^]

I hope this will help to you.


这篇关于文字改变了事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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