Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
CListCtrl::GetNextSelectedItem
Collapse the table of content
Expand the table of content

CListCtrl::GetNextSelectedItem

Gets the index of the list item identified by pos, then sets pos to the POSITION value.

int GetNextSelectedItem( 
   POSITION& pos  
) const;

pos

A reference to a POSITION value returned by a previous call to GetNextSelectedItem or GetFirstSelectedItemPosition. The value is updated to the next position by this call.

The index of the list item identified by pos.

You can use GetNextSelectedItem in a forward iteration loop if you establish the initial position with a call to GetFirstSelectedItemPosition.

You must ensure that your POSITION value is valid. If it is invalid, then the Debug version of the Microsoft Foundation Class Library asserts.

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
			}
		}

Header: afxcmn.h

Show:
© 2015 Microsoft