Condividi tramite


CListCtrl::GetFirstSelectedItemPosition

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.

Example

The following code sample demonstrates the usage of this function.

POSITION pos = m_myListCtrl.GetFirstSelectedItemPosition();
if (pos == NULL)
{
   TRACE(_T("No items were selected!\n"));
}
else
{
   while (pos)
   {
      int nItem = m_myListCtrl.GetNextSelectedItem(pos);
      TRACE(_T("Item %d was selected!\n"), nItem);
      // you could do your own processing on nItem here
   }
}

Requirements

Header: afxcmn.h

See Also

Concepts

CListCtrl Class

CListCtrl Members

Hierarchy Chart

CImageList Class

CListCtrl::GetNextSelectedItem