Export (0) Print
Expand All

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.


// 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);
   }


Header: afxwin.h

Community Additions

ADD
Show:
© 2014 Microsoft