Combo Box中怎样将所选中的当前项输出到一个变量中?请各位大侠多多指教!!!

解决方案 »

  1.   

    CComboBox::GetCurSel
    int GetCurSel( ) const;Return ValueThe zero-based index of the currently selected item in the list box of a combo box, or CB_ERR if no item is selected.ResCall this member function to determine which item in the combo box is selected. GetCurSel returns an index into the list.Example// The pointer to my combo box.
    extern CComboBox* pmyComboBox;// Select the next item of the currently selected item 
    // in the combo box.
    int nIndex = pmyComboBox->GetCurSel();
    int nCount = pmyComboBox->GetCount();
    if ((nIndex != LB_ERR) && (nCount > 1))
    {
       if (++nIndex < nCount)
          pmyComboBox->SetCurSel(nIndex);
       else
          pmyComboBox->SetCurSel(0);
    }要里面的text的话配合下面的函数
    int GetLBText( int nIndex, LPTSTR lpszText ) const;void GetLBText( int nIndex, CString& rString ) const;
      

  2.   

    CString sReture;
    m_ComboBox.GetLBText(m_ComboBox.GetCurSel(),sReture);