Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic


Gets the position of the first selected item in the list view control.

POSITION GetFirstSelectedItemPosition( ) const;

Return Value

A POSITION value that can be used for iteration or object pointer retrieval; NULL if no items are selected.


The 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");
   while (pos)
      int nItem = pList->GetNextSelectedItem(pos);
      TRACE1("Item %d was selected!\n", nItem);
      // you could do your own processing on nItem here

See Also

CListCtrl Overview | Class Members | Hierarchy Chart | CImageList | CListCtrl::GetNextSelectedItem

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.