MFC 做一个简单过滤的combobox


ON_CBN_EDITCHANGE(84530, OnEditChanged)

void CClassA::OnEditChanged()
{
   CString strObj;
   m_cbb.GetWindowText(strObj);
   m_cbb.ResetContent();
   
    /*
    循环查找下拉框中原来添加的所有数据项,是否存在匹配的字符
    for(..strName..) 
    {
        if(strName.Find(strObj) >= 0)
        {
            m_cbb.AddString(strName);
        }
    }
    */

    ::SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)));
    m_cbb.ShowDropDown();
    if (m_cbb.GetCount() == 1)
    {
        m_cbb.SetCurSel(0);
    }
    m_cbb.SetWindowText(strObj);
    m_cbb.SetEditSel(strObj.GetLength(), strObj.GetLength());
}

 

你可能感兴趣的:(技术类,mfc,c++)