1.添加头文件#include <afxtempl.h>
2.添加代码 m_courseList为添加的ClistBox变量
3.取消选择
2.添加代码 m_courseList为添加的ClistBox变量
int nCount = m_courseList.GetSelCount(); //获得被选中的行数
CString cCount;
CArray<int,int> aryListBoxSel;
aryListBoxSel.SetSize(nCount);
m_courseList.GetSelItems(nCount, aryListBoxSel.GetData());
//得到总数
cCount.Format(_T("%d"),nCount);
AfxMessageBox(cCount);
//得到选中的多项
for (int i=0;i<nCount;i++)
{
CString selStr;
selStr="";
m_courseList.GetText(aryListBoxSel[i],selStr);
AfxMessageBox(selStr);
}
3.取消选择
int ncount=m_courseList.GetCount();//获得行数
for(int i=0;i<ncount;i++)
{
m_courseList.SetSel(i,false);//设置为未被选中状态
}