padraigf padraigf -3 years ago 150
C++ Question

Setting selection by text in CComboBox (MFC)

I have a CComboBox of type

(i.e. it's not editable). What's the easiest way to set the current selection by string?

I know I can use
to set it by index, but I want the function to search through the list-items by string and set it.

Answer Source

What about CComboBox::SelectString ?

"Searches for a string in the list box of a combo box, and if the string is found, selects the string in the list box and copies it to the edit control."

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download