CComboBox myComboBox; myComboBox.AddString(_T("Item 1")); myComboBox.AddString(_T("Item 2")); myComboBox.SetCurSel(0);
CComboBox myComboBox; myComboBox.AddString(_T("Item 1")); myComboBox.AddString(_T("Item 2")); int selectedIndex = myComboBox.FindStringExact(-1, _T("Item 2")); myComboBox.SetCurSel(selectedIndex);This code creates a combo box control, adds two items to it, and searches for the "Item 2" string in the control. If found, the index of the item is used to set the currently selected item. Package/library: MFC (Microsoft Foundation Class) library.