Share via


CComboBox::SelectString

intSelectString(intnStartAfter**,LPCTSTRlpszString);**

Return Value

The zero-based index of the selected item if the string was found. If the search was unsuccessful, the return value is CB_ERR and the current selection is not changed.

Parameters

nStartAfter

Contains the zero-based index of the item before the first item to be searched. When the search reaches the bottom of the list box, it continues from the top of the list box back to the item specified by nStartAfter. If –1, the entire list box is searched from the beginning.

lpszString

Points to the null-terminated string that contains the prefix to search for. The search is case independent, so this string can contain any combination of uppercase and lowercase letters.

Remarks

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.

A string is selected only if its initial characters (from the starting point) match the characters in the prefix string.

Note that the SelectString and FindString member functions both find a string, but the SelectString member function also selects the string.

Example

// The pointer to my combo box.
extern CComboBox* pmyComboBox;
// The string to match.
extern LPCTSTR lpszmyString;

// Select the item that begins with the specified string.
int nIndex = pmyComboBox->SelectString(0, lpszmyString);
ASSERT(nIndex != LB_ERR);

CComboBox OverviewClass MembersHierarchy Chart

See Also   CComboBox::FindString,