CComboBox::FindString
查找,但不会选择,在组合框的列表框包含指定的前缀的第一个字符串。
int FindString(
int nStartAfter,
LPCTSTR lpszString
) const;
参数
nStartAfter
在要搜索的第一项之前包含项的从零开始的索引。 在搜索到达列表框的底部时,它从列表框的顶部继续回 nStartAfter指定的项。 如果– 1,整个列表框从开始处搜索。lpszString
指向包含标题搜索的Null终止的字符串。 搜索区分大小写的,因此,此字符串可以包含大写和小写字母的任意组合。
返回值
如果返回值大于或等于0,这是匹配项的从零开始的索引。 如果搜索不成功,它是 CB_ERR。
备注
此功能不是由Windows ComboBoxEx 控件支持。 有关此控件的更多信息,请参见 Windows SDK的 ComboBoxEx控件。
示例
// The string to match.
LPCTSTR lpszmyString = _T("item");
// Delete all items that begin with the specified string.
int nItem = 0;
while ((nItem = m_pComboBox->FindString(nItem, lpszmyString)) != CB_ERR)
{
m_pComboBox->DeleteString(nItem);
}
要求
Header: afxwin.h