CComboBox::FindStringExact
调用 FindStringExact 成员函数找到第一个列表框字符串(在组合框)匹配一 lpszFind指定的字符串。
int FindStringExact(
int nIndexStart,
LPCTSTR lpszFind
) const;
参数
nIndexStart
在要搜索的第一项之前指定项的从零开始的索引。 在搜索到达列表框的底部时,它从列表框的顶部继续回 nIndexStart指定的项。 如果 nIndexStart 为– 1,整个列表框从开始处搜索。lpszFind
指向一个Null终止的字符串搜索。 此字符串可以包含完整文件名,包括该扩展。 搜索不区分大小写,因此,此字符串可以包含大写和小写字母的任意组合。
返回值
匹配项的从零开始的索引或 CB_ERR,如果搜索不成功。
备注
如果组合框已创建使用所有者描述样式,但,而无需 CBS_HASSTRINGS 样式,FindStringExact 尝试双字值与 lpszFind相符的值。
示例
// The string to match.
LPCTSTR lpszmyExactString = _T("item 5");
// Delete all items that exactly match the specified string.
int nDex = 0;
while ((nDex = m_pComboBox->FindStringExact(nDex, lpszmyExactString))
!= CB_ERR)
{
m_pComboBox->DeleteString(nDex);
}
要求
Header: afxwin.h