Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

CListBox::GetSel 

Retrieves the selection state of an item.


int GetSel(
   int nIndex 
) const;

Parameters

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.

// The pointer to my list box.
extern CListBox* pmyListBox;

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

Community Additions

ADD
Show:
© 2015 Microsoft