ListCtrl 选中某项

void CWndSendDataCProView::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult) 
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;

CListCtrl &listCtrl = GetListCtrl();  

CString strName = "";
CString strSex = "";
CString strAge = "";

POSITION pos = listCtrl.GetFirstSelectedItemPosition();
if (pos == NULL)
{
}
else
{
while (pos)
{
int iItem = listCtrl.GetNextSelectedItem(pos);
strName = listCtrl.GetItemText(iItem, 0);
strSex = listCtrl.GetItemText(iItem, 1);
strAge = listCtrl.GetItemText(iItem, 2);

//strName = listCtrl.GetItemText(pNMListView->iItem, 0);
//strSex = listCtrl.GetItemText(pNMListView->iItem, 1);
//strAge = listCtrl.GetItemText(pNMListView->iItem, 2);

myEdit.SetSel(0, myEdit.GetWindowTextLength());
myEdit.ReplaceSel(strName + "\t" + strSex + "\t" + strAge);
}
}
*pResult = 0;
}

你可能感兴趣的:(C++)