By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,455 Members | 1,430 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,455 IT Pros & Developers. It's quick & easy.

Help with KeyPress on comboBox! Code included!

P: n/a
Ok, I have been researching this problem for the past two hours (at least!)
and I just can't seem to figure it out. So I broke down and decided to post
some code for some of you gurus to look at.

When running the code, don't forget to add the autoCompleteComboBox.dll file
which is included.

I hope it's not inappropiate to post code here. Please let me know if it
is.

On the surface the code really isn't that complicated. It works like
this...

1) The user presses F3
2) The KeyUp event is lauched (on the form) and the comboBoxes are cleared
(not the actual items, but the top part - where the user types).

But it doesn't seem to work. Help!

You can download my code file here...
http://www.mnik.com/temp/app1.zip
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi!
The problem is that the keypreview doesn't work with comboboxes.
So, you must use the event KeyUp from every combobox.
Hope that helps.
Best regards.
Nov 16 '05 #2

P: n/a
There's something wrong with the AutoCompleteComboBox, in order to get the
code to work properly I had to set the text = "" twice...

private void Form1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode==Keys.F3)
{
e.Handled = ClearComboBox ( autoCompleteComboBox1 )
|| ClearComboBox ( autoCompleteComboBox2 );
}
}

private bool ClearComboBox( AutoCompleteComboBox.AutoCompleteComboBox
accb )
{
if ( accb.Focused )
{
accb.SelectAll();
accb.Refresh();
accb.Text = "";
accb.Text = "";
return true;
}

return false;
}
Hope that helps.

Dan.

"Keith Smith" <ke*********@verizon.net> wrote in message
news:RZoXd.43080$uc.36190@trnddc01...
Ok, I have been researching this problem for the past two hours (at
least!)
and I just can't seem to figure it out. So I broke down and decided to
post
some code for some of you gurus to look at.

When running the code, don't forget to add the autoCompleteComboBox.dll
file
which is included.

I hope it's not inappropiate to post code here. Please let me know if it
is.

On the surface the code really isn't that complicated. It works like
this...

1) The user presses F3
2) The KeyUp event is lauched (on the form) and the comboBoxes are
cleared
(not the actual items, but the top part - where the user types).

But it doesn't seem to work. Help!

You can download my code file here...
http://www.mnik.com/temp/app1.zip

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.