CListBox::GetSel

检索项的选择状态。

int GetSel(
   int nIndex 
) const;

参数

  • nIndex
    指定项的从零开始的索引。

返回值

一个正数,如果指定的项选择;否则,为0。 如果发生错误,则返回值是 LB_ERR。

备注

此成员函数使用单和多重选择使用列表框。

若要检索当前所选的索引列表框项,请使用 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);
   }

要求

标头: afxwin.h

请参见

参考

CListBox选件类

层次结构图

LB_GETSEL

CListBox::SetSel

CListBox::GetCurSel