CListCtrl::GetSelectedCount UINT GetSelectedCount( ) const;Return ValueThe number of selected items in the list view control.ResRetrieves the number of selected items in the list view control.CListCtrl Overview | Class Members | Hierarchy ChartSee Also CListCtrl::SetItemCount, CListCtrl::GetItemCount
CListCtrl::GetFirstSelectedItemPosition POSITION GetFirstSelectedItemPosition( ) const;Return ValueA POSITION value that can be used for iteration or object pointer retrieval; NULL if no items are selected.ResGets the position of the first selected item in the list view control.ExampleThe following code sample demonstrates the usage of this function.CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_YOURLISTCONTROL); ASSERT(pListCtrl != NULL);POSITION pos = pList->GetFirstSelectedItemPosition(); if (pos == NULL) TRACE0("No items were selected!\n"); else { while (pos) { int nItem = pList->GetNextSelectedItem(pos); TRACE1("Item %d was selected!\n", nItem); // you could do your own processing on nItem here } }CListCtrl Overview | Class Members | Hierarchy ChartSee Also CImageList, CListCtrl::GetNextSelectedItem
UINT GetSelectedCount( ) const;Return ValueThe number of selected items in the list view control.ResRetrieves the number of selected items in the list view control.CListCtrl Overview | Class Members | Hierarchy ChartSee Also CListCtrl::SetItemCount, CListCtrl::GetItemCount
POSITION GetFirstSelectedItemPosition( ) const;Return ValueA POSITION value that can be used for iteration or object pointer retrieval; NULL if no items are selected.ResGets the position of the first selected item in the list view control.ExampleThe following code sample demonstrates the usage of this function.CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_YOURLISTCONTROL);
ASSERT(pListCtrl != NULL);POSITION pos = pList->GetFirstSelectedItemPosition();
if (pos == NULL)
TRACE0("No items were selected!\n");
else
{
while (pos)
{
int nItem = pList->GetNextSelectedItem(pos);
TRACE1("Item %d was selected!\n", nItem);
// you could do your own processing on nItem here
}
}CListCtrl Overview | Class Members | Hierarchy ChartSee Also CImageList, CListCtrl::GetNextSelectedItem
如果是多选,则使用楼上说的