6
votes

I need a combobox in an Windows MFC application that has a search feature. It should work so that if you start typing something that matches one or more items in the list, the combobox should drop-down and display those items. Kinda like popular ajax-based search boxes on the web

Do you - know of any control that provides this functionality? - have a link to information on how to create such functionality myself? - have ideas on how to do this that you could share?

3

3 Answers

0
votes

Provide a handler for the CBN_EDITCHANGE event, your handler willö be called every time the user changes the text in the edit field.

In this Handler, call the CComboBox::FindString() method to see if the typed text exists in any of your combobox entries. If it does, call CComboBox::SetCurSel() to select it.

-1
votes

It's a Win32 api FAQ. See Adv. Win32 api ng news://194.177.96.26/comp.os.ms-windows.programmer.win32 (you don't need at all CBN_EDITCHANGE. It's automatic with api)

-1
votes

Full access to the edit box of the combo box:

CEdit *pEdit = (CEdit *)pComboBox->GetWindow(GW_CHILD);