我做了一个组合框,并为其定义如下(通过classwizard定义的)
CComboBox  m_ctrSinger;
我在旁边做了一个按钮,是为了清空这个组合框而设计的,我在这个按钮的click事件响应函数中加入了一条这样的语句:
m_ctrSinger.Clear();
编译完全通过,正确执行程序,但是当我从已有值的下拉列表选一个值到上面的组合框中后,点击按钮,居然不清空,我不知道什么原因,难道还有什么没有注意吗?

解决方案 »

  1.   

    m_ctrSinger.SetFocus ();
    m_ctrSinger.Clear();
      

  2.   

    如果没记错的话应该用:m_ctrSinger.ResetContent()
      

  3.   

    如果我没记错的话,应该是
    m_ctrSinger.ResetContent()
      

  4.   

    楼上说得对,clear只是清除当前选中的内容,resetcontent()才是清空所有内容
      

  5.   

    CComboBox *pmyComboBox;for (int i=0;i < pmyComboBox->GetCount();i++)
    {
       pmyComboBox->DeleteString( i );
    }
      

  6.   

    m_ctrSinger.ResetContent();不会有错
      

  7.   

    楼上说得对,Clear()是清除当前选中的内容,ResetContent()才是清空所有内容。
      

  8.   

    使用ResetContent();请使用前仔细看看msdn
    CComboBox::Clear
    void Clear( );ResDeletes (clears) the current selection, if any, in the edit control of the combo box. clear是删除选中的项。
      

  9.   

    GetDlgItem(***)->SetWindowText("");