CComboBox::GetCurSel

更新 : 2007 年 11 月

コンボ ボックスの項目が選択されているかどうかを調べます。

int GetCurSel( ) const;

戻り値

コンボ ボックスのリスト ボックスで現在選択されている項目の 0 から始まるインデックスを返します。選択されている項目がない場合は、CB_ERR を返します。

解説

GetCurSel はリスト内のインデックスを返します。

使用例

// Select the next item of the currently selected item 
// in the combo box.
int nIndex = m_pComboBox->GetCurSel();
int nCount = m_pComboBox->GetCount();
if ((nIndex != CB_ERR) && (nCount > 1))
{
   if (++nIndex < nCount)
      m_pComboBox->SetCurSel(nIndex);
   else
      m_pComboBox->SetCurSel(0);
}

必要条件

ヘッダー : afxwin.h

参照

参照

CComboBox クラス

階層図

CComboBox::SetCurSel

CB_GETCURSEL

その他の技術情報

CComboBox のメンバ