VC中使用combo box控件,想动态增加一项,任意删除一项或多项,也可整体删除,请高手指点

解决方案 »

  1.   

    查MSDN啊
    // The pointer to my combo box.
    extern CComboBox* pmyComboBox;// Add 20 items to the combo box.
    CString str;
    for (int i=0;i < 20;i++)
    {
       str.Format(_T("item string %d"), i);
       pmyComboBox->AddString( str );
    }
    // The pointer to my combo box.
    extern CComboBox* pmyComboBox;// Delete every other item from the combo box.
    for (int i=0;i < pmyComboBox->GetCount();i++)
    {
       pmyComboBox->DeleteString( i );
    }
      

  2.   

    /*! 新增字符串项 */
    CComboBox m_cbPort;
    m_cbPort.AddString(LPCTSTR str);
    /*! 删除指定项 */
    m_cbPort.DeleteString(int iIndex);
    /*! 清除所有项 */
    m_cbPort.Clear();