首页 > 代码库 > CComboBox自动匹配

CComboBox自动匹配

void CLoadPhotoDlg::OnCbnEditchangeCombo1() {  // TODO: 在此添加控件通知处理程序代码  UpdateData(TRUE);  CComboBox *ctr_goodsName = (CComboBox *)GetDlgItem(IDC_COMBO1);

 //清空列表  for (int i=(ctr_goodsName->GetCount()-1);i>-1;i--)  {   ctr_goodsName->DeleteString(i);  }  //

 vector<CString> vet_goodsName = FindXml(_T("GOODSNAME"));

 if (vet_goodsName.size()!=0 && m_ccValue.IsEmpty() == FALSE)  {   for (int i=0;i<vet_goodsName.size();i++)   {    if (vet_goodsName.at(i).Find(m_ccValue) != -1)    {     if (ctr_goodsName->GetCount() == 0)     {      ctr_goodsName->AddString(m_ccValue);     }     ctr_goodsName->AddString(vet_goodsName.at(i));    }   }

  if (ctr_goodsName->GetCount() != 0)   {    ctr_goodsName->SetCurSel(0);    ctr_goodsName->ShowDropDown(TRUE);//强制打开列表框      SetCursor(LoadCursor(NULL,MAKEINTRESOURCE(IDC_ARROW)));//    ctr_goodsName->SetWindowTextW(m_ccValue);    ::SendMessageA(ctr_goodsName->m_hWnd,WM_KEYDOWN,VK_END,0);   }   else   {    ctr_goodsName->ShowDropDown(FALSE);   }  }  else  {   ctr_goodsName->ShowDropDown(FALSE);  }   }

vector<CString> CLoadPhotoDlg::FindXml(CString nodeName) {  vector<CString> val;  CMarkup xml;  BOOL is;

 is = xml.Load(_T("E:\\orderAddInit.xml"));  while ( xml.FindChildElem(_T("GOODSNAME")))  { //  xml.IntoElem();   val.push_back(xml.GetChildData());  }  return val; }