CListBox::GetSel

更新 : 2007 年 11 月

項目の選択状態を取得します。

int GetSel(
   int nIndex 
) const;

パラメータ

  • nIndex
    項目を 0 から始まるインデックスで指定します。

戻り値

指定した項目が選択されている場合は、正の値を返します。それ以外の場合は 0 を返します。エラーが発生した場合は、LB_ERR を返します。

解説

このメンバ関数は、単一選択リスト ボックスでも複数選択リスト ボックスでも使用できます。

使用例

// 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 のメンバ