This documentation is archived and is not being maintained.


Retrieves the zero-based index of the currently selected item, if any, in a single-selection list box.

int GetCurSel( ) const;

The zero-based index of the currently selected item if it is a single-selection list box. It is LB_ERR if no item is currently selected.

In a multiple-selection list box, the index of the item that has the focus.

Do not call GetCurSel for a multiple-selection list box. Use CListBox::GetSelItems instead.

// Select the next item of the currently selected one.
int nIndex = m_myListBox.GetCurSel();
int nCount = m_myListBox.GetCount();
if ((nIndex != LB_ERR) && (nCount > 1))
   if (++nIndex < nCount)

Header: afxwin.h