Click here to Skip to main content
15,915,603 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my combobox has following


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


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.
Posted

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
 
Share this answer
 
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[^]
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 22-Apr-12 22:00pm    
Apparently it is more suitable, a 5.
--SA
VJ Reddy 22-Apr-12 22:29pm    
Thank you, SA.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900