MFC中在Clistbox查找字符串

[复制链接]
查看11 | 回复1 | 2010-6-13 10:52:52 | 显示全部楼层 |阅读模式
Clistbox *pList1;
CString strtmp,m_key1;
for
pList1->GetText(i,strtmp);
find=pList1->SelectString(-1,m_key1);//这句执行到这儿会出错,不知道为什么?
pList1=&m_lstLink;
nCount=pList1->GetCount();
for(i=0;iGetText(i,strtmp);
find=pList1->SelectString(-1,m_key1);
if(find==LB_ERR)
{
MessageBox("no find");
}
else
pList1->DeleteString(i);
}

回复

使用道具 举报

千问 | 2010-6-13 10:52:52 | 显示全部楼层
在没查找到字符串的时候,你执行了pList1->DeleteString(i);删掉了一个listbox的数据。外面又有个for循环,pList1->GetText(i,strtmp);就越界了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行