ComboBox AutoComplete Issue


E

ezyeric13

I have a series of ComboBox's Bound to a DataGridView and I turned the
AutoComplete on for them so they list all the items in a certain
collumn of the DataGridView.

The problem is that when you use the Tab key to finish the
Autocomplete it both selects that item and moves to the next Control
in the Tab Order.

I personally prefer to use the Enter key (to select autocomplete
items) but many users are used to the Tab key.

Know of any way I can prevent the Tab key from moving to the next
control when its used inside the Autocomplete droplist?

Thanks
 
Ad

Advertisements

P

Peter Duniho

[...]
Know of any way I can prevent the Tab key from moving to the next
control when its used inside the Autocomplete droplist?

Sounds like a feature to me. Assuming the tab key normally moves focus
between controls, why should it not also move focus when you're
autocompleting?

But, if you really want to disable this feature, it seems to me that you
could override the IsInputKey method and return true for the Tab key.

Of course, it's possible that doing so would disable the auto-complete
functionality of the Tab key. I don't have a good answer for that. :)
You might as well try it and see. It's also possible that it *won't*
disable the auto-complete functionality.

Pete
 
G

Guest

Have a look at creating a userControl inheriting the ComboBox and then using
the keypress event to see which key has been pressed and if it is Tab ignore.
 
P

Peter Duniho

[...]
Of course, it's possible that doing so would disable the auto-complete
functionality of the Tab key. I don't have a good answer for that. :)
You might as well try it and see. It's also possible that it *won't*
disable the auto-complete functionality.

I tried this, and it does disable the autocomplete functionality (that is,
it doesn't "complete" the autocomplete). But if you are using the
"Append" mode for the autocomplete, then just calling SelectAll() in your
override when you return true for Keys.Tab does essentially the same thing.

I haven't figured out a way to handle the autocomplete in the case when
you are using "Suggest" mode, but my guess is you could do it if you
really wanted to.

Pete
 
M

Mr. Arnold

I have a series of ComboBox's Bound to a DataGridView and I turned the
AutoComplete on for them so they list all the items in a certain
collumn of the DataGridView.

The problem is that when you use the Tab key to finish the
Autocomplete it both selects that item and moves to the next Control
in the Tab Order.

I personally prefer to use the Enter key (to select autocomplete
items) but many users are used to the Tab key.

Know of any way I can prevent the Tab key from moving to the next
control when its used inside the Autocomplete droplist?

Thanks

Doesn't the Combox have a Keypress event where you can ignore the Tab-Key
Ascii code by returning KeyAscii = 0?
 
P

Peter Duniho

Have a look at creating a userControl inheriting the ComboBox and then
using the keypress event to see which key has been pressed and if it is
Tab ignore.

The KeyPress event will never indicate a Tab character by default. Only
if the IsInputKey is overridden and it returns true when the Tab key is
pressed will the control get a KeyPress event for the Tab key. And of
course, by the time that happens, the original issue (the Tab key changing
focus) has been resolved, obviating any need to do additional processing
in the KeyPress event.

Pete
 
Ad

Advertisements

E

ezyeric13

BTW I am using SuggestAppend for the AutoComplete.

I dont want to totally kill tab for these ComboBox's. It seems like
there should be some object or Event for the AutoComplete list and I
could check for that event to be fired and if so, then override the
tab for the combo.

When you use the Intellisense AutoComplete when writing code and hit
Tab / Enter it just does the autocomplete and not the Tab / Enter
also , so you would think that should be the default behavior for most
controls, guess not.

I wish everyone would just use Enter, haha.

Oh well thanks for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top