Question

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?

Was it helpful?

Solution

Found this:

http://www.codeguru.com/cpp/controls/combobox/article.php/c1807/

Renamed the class since CComboBoxEx is now part of MFC, and added a ShowDropDown() call in OnEditUpdate().

OTHER TIPS

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)

Full access to the edit box of the combo box:

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

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

Can I get access to the ListBox part in a similar way? Need to clear the contents of the list, e.g. using ResetContent.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top