tags:

views:

71

answers:

1

I have a dropdown-list style CComboBox on a form. The nice thing about this style is it allows for type ahead--that is, you can type a character and it will jump to the first item in the list matching that character. However, there are certain items which need to be excluded from this behavior. How might this be accomplished?

+1  A: 

Just as a simple (and maybe ugly) "trick" idea: Can you mask the items you want to exclude from type ahead search by any special character, like * as first character for instance? (So you would add to the ComboBox *MyItemText instead of MyItemText.) If your item list needs to be sorted you have to switch off the autosort property of the ComboBox and do your own sorting (without the *) before you add the items to the ComboBox. Users would also recognize that this is an item not to be found by type ahead (if this makes any sense or should be useful in your application).

The CComboBox does not have any Edit or TextChanged event. So my guess is that for another better solution you have to go the hard way and evaluate single keyboard events and run own your search through the item list. I don't have a better idea.

Slauma
Yeah, the item I'm trying to skip actually starts with a bracket '[', so I don't think your suggestion will work (good idea though).
drewh
It is indeed surprising: An item `[ccc` is found if I enter `c` in the ComboBox but `*ccc` is NOT found and in fact skipped in the search. Something I wouldn't believe if I hadn't it just tested :)
Slauma