CListBox::SelectString
intSelectString(intnStartAfter**,LPCTSTRlpszItem);**
Return Value
The index of the selected item if the search was successful. If the search was unsuccessful, the return value is LB_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 nStartAfter is –1, the entire list box is searched from the beginning.
lpszItem
Points to the null-terminated string that contains the prefix to search for. The search is case independent, so this string may contain any combination of uppercase and lowercase letters.
Remarks
Searches for a list-box item that matches the specified string, and if a matching item is found, it selects the item.
The list box is scrolled, if necessary, to bring the selected item into view.
This member function cannot be used with a list box that has the LBS_MULTIPLESEL style.
An item is selected only if its initial characters (from the starting point) match the characters in the string specified by lpszItem.
Use the FindString member function to find a string without selecting the item.
Example
// The pointer to my list box.
extern CListBox* pmyListBox;
// The string to match.
extern LPCTSTR lpszmyString;
// Select the item that begins with the specified string.
int nIndex = pmyListBox->SelectString(0, lpszmyString);
ASSERT(nIndex != LB_ERR);
CListBox Overview | Class Members | Hierarchy Chart
See Also CListBox::FindString,