MFC CListBox类如何储存背后数据和拿出里面储着的数据出来?

来源:百度知道 编辑:UC知道 时间:2024/06/26 02:57:16
MFC CListBox类如何储存背后数据和拿出里面储着的数据出来?

如现在有个CListBox类的对象list

储存背后数据和拿出里面储着的数据出来!!!!

那数据不是项目名字啊!!!

BOOL CCListIconDlg::OnInitDialog()
{ CString str;
for(i = 0; i < 8; i ++)
{
str.Format("第%d行",i);
m_ListBox.InsertString(i,str);
m_ListBox.SetItemData(i,1000 + i);
}
}

void CCListIconDlg::OnSelchangeList3()
{
// TODO: Add your control notification handler code here
int iTem = m_ListBox.GetCurSel();
if(iTem < m_ListBox.GetCount())
{
int n = m_ListBox.GetItemData(iTem);
CString s;
s.Format("%d",n);
MessageBox(s);

}
}