This documentation is archived and is not being maintained.

CComboBox::FindString 

Finds, but doesn't select, the first string that contains the specified prefix in the list box of a combo box.


int FindString(
   int nStartAfter,
   LPCTSTR lpszString 
) const;

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.

If the return value is greater than or equal to 0, it is the zero-based index of the matching item. It is CB_ERR if the search was unsuccessful.

This function is not supported by the Windows ComboBoxEx control. For more information on this control, see ComboBoxEx Controls in the Platform SDK.

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

// Delete all items that begin with the specified string.
int nIndex = 0;
while ((nIndex=pmyComboBox->FindString(nIndex, lpszmyString)) != CB_ERR)
{
   pmyComboBox->DeleteString( nIndex );
}
Show: