文本已更改事件的问题 [英] Problem for textchanged event

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

问题描述

在我的组合框中有以下内容


In my combobox has following


tableno
1
1-1
1-2
1-3
1-4
2
2-1



我从数据库表中找到了与输入的表相同的首选项

用户可能正在组合框上进行选择或键入.因此,我为Textchanged事件提供了查询.但是,每次键入文本时都会发生问题,Textchanged事件正在调用.
当我键入1-1时,该事件将被调用三次,因此将显示错误msgbox三次.因此,请任何人帮助哪个事件适合此问题.

帮帮我.



I find the Preferences from database table which is equalent to entered tableno

The user may be selecting or typing on the combobox. So I give the query for Textchanged event. But the problem occured everytime type the text, the Textchanged event is calling.
When I type 1-1, three times the event is calling, So three times the error msgbox is displays. So please anybody help which event is suitable for this problem.

Help me.

推荐答案

这里的问题是,每当您更改组合框的文本时,文本更改甚至会累累

所以这个
您可以将代码移至key_down事件,并且可以按垂直键执行代码
说回车键
像这样
如果(e.KeyCode == Keys.Enter)
{
您的代码在这里
}
这样,您的代码仅在您按Enter键时才会执行
Here the problem is that textchanged even accures each time you change the text of combobox

so for this
you can move your code to key_down event and you can execute your code on press of perticular key
say enter key
like this
if (e.KeyCode == Keys.Enter)
{
your code goes here
}
in this way your code will execute only when you will press enter key


我认为SelectedIndexChanged事件更适合于此目的,如此处所述
http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.selectedindexchanged.aspx [ ^ ]
I think the SelectedIndexChanged event is more suitable for this purpose as explained here
http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.selectedindexchanged.aspx[^]


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

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