|
Hi all,
I have a textbox with autocomplete set to suggest.
I want to execute my code in the Textbox_KeyDown event on the enter key,
but enter key is also invoked when I select an item from the text box autocomplete items.
That is not what I want.
I want the selected item in the textbox and then execute my code.
code:
private void opdrverwTextbox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == (Keys.Enter) && !string.IsNullOrEmpty(opdrverwTextbox.Text))
{
e.Handled = true;
a lot of other code........;
}
opdrverwTextbox.Clear();
opdrverwTextbox.Visible = false;
opdrverwLabel.Visible = false;
dataGridView_Update();
}
}
I don't want to set autocomplete to suggest-append.
is there a workaround for this?
Merry Christmas,
Groover
b>
0200 A9 23
0202 8D 01 80
0205 00
|
|
|
|
|
Hi all,
Found a solution myself after long google search.
It works but can someone explain how?
here is my new code:
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern short GetKeyState(Keys key);
private void opdrverwTextbox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == (Keys.Enter) && !string.IsNullOrEmpty(opdrverwTextbox.Text)&&
GetKeyState(Keys.Enter) < 0)
{
e.Handled = true;
a lot of other code........;
}
opdrverwTextbox.Clear();
opdrverwTextbox.Visible = false;
opdrverwLabel.Visible = false;
dataGridView_Update();
}
Groover,
0200 A9 23
0202 8D 01 80
0205 00
|
|
|
|