共用方式為


CComboBox::GetCurSel

呼叫此成員函式以判斷在下拉式方塊中選取哪個項目。

int GetCurSel( ) const;

傳回值

目前選取項目之以零起始的索引在下拉式方塊的清單方塊中的 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);
}

需求

Header: afxwin.h

請參閱

參考

CComboBox 類別

階層架構圖

CComboBox::SetCurSel

CB_GETCURSEL