Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CListBox::GetSel

 

Retrieves the selection state of an item.


      int GetSel(
   int nIndex 
) const;

nIndex

Specifies the zero-based index of the item.

A positive number if the specified item is selected; otherwise, it is 0. The return value is LB_ERR if an error occurs.

This member function works with both single- and multiple-selection list boxes.

To retrieve the index of the currently-selected list box item, use CListBox::GetCurSel.

Example

// Dump all of the items select state.
   CString str;
   for (int i=0;i < m_myListBox.GetCount();i++)
   {
      str.Format(_T("item %d: select state is %s\r\n"),
         i,
         m_myListBox.GetSel( i ) > 0 ? _T("true") : _T("false"));
      AFXDUMP(str);
   }

Requirements

Header: afxwin.h

Show: