|
-
September 28th, 2010, 03:39 PM
#1
[RESOLVED] KeyPress, KeyCode handling behavior strange
Hi all,
I basically want to have a combo that lists some account codes (e.g ALB1E, BSE2F) and when the user types the first few letters and presses enter, I calla function that will get all matching acocunt codes (e.g when they type ALB, it will show all ALB%) and populate them in a combo.
The problem is when I handle e.keycode == Enter, it gets called TWICE and the resulting is a wrong search results.
Code:
private void cmbAccountCodes_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
GetDeliveryPoints(cmbAccountCodes.Text.Trim()); //gets the data I want to populate and adds it to the combo as well
}
}
So, when I press ALB and press Enter, it egts matching results like ALB10Q, ALB67Y, ALB40W etc and populates them in a combo. But then, this method gets called again somehow, and this time the first item in the combo is selected ( int his case its ALB10Q) and then it searches again for ALB10Q% passing it as param to GetDeliveryPoints() which I do not want. Why is the KeyDown method called twice? Thanks for the help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|