void CPowerDlg::OnEditchangeCombo() 
{
// TODO: Add your control notification handler code here
CComboBox * m_combo = (CComboBox *)GetDlgItem(IDC_COMBO);
int nselect = m_combo->GetCurSel();
m_combo->GetLBText(nselect,m_szCom);
}请问,m_szCom在这段代码可以得到下拉框所选定值吗?

解决方案 »

  1.   

    CString* m_szCom ;???就可以
      

  2.   

    请问,m_szCom在这段代码可以得到下拉框所选定值吗?
    ========
    可以啊,没有问题
      

  3.   

       CString str, str2;
       int n;
       for (int i=0;i < pmyComboBox->GetCount();i++)
       {
          n = pmyComboBox->GetLBTextLen( i );
          pmyComboBox->GetLBText( i, str.GetBuffer(n) );
          str.ReleaseBuffer();      str2.Format(_T("item %d: %s\r\n"), i, str.GetBuffer(0));
          afxDump << str2;
       }
      

  4.   

    没这样做过,一般都是和combox关联一个数组,用选择的index直接从数组取值。
      

  5.   

    我只是想在选定下拉框值的时候把显示的字符串传给m_szCom这个CString类型的变量,到底该怎么做啊,疯了,弄了好几天了
      

  6.   

    m_combo->GetLBText(nselect,m_szCom);
    这样可以啊,怎么不行了?
      

  7.   

    可以
    CString strText(_T(""));
    CComboBox::GetLBText(CComboBox::GetCurSel(), strText);
      

  8.   

    int pos;
    CString strpos;
    int pos = m_Comb.GetCurSel();
    m_Comb.GetLBText(pos,strpos);
    这样就可以了吧
      

  9.   

    这样不行 一改变 框内的数值 就会运行时的错误, 楼主可以给 combobox 关联一个 CString 变量m_str
    然后
    void CEditDlg::OnEditchangeCombo1() 
    {
    // TODO: Add your control notification handler code here
    UpdateData();
    MessageBox(m_str);
    }
      

  10.   

    无奈了,换成radio好用了,不折腾下拉框了,谢谢大家了