Поделиться через


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.

Пример

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

См. также

Основные понятия

CListBox Class

CListBox Members

Hierarchy Chart

LB_GETSEL

CListBox::SetSel