方法如下: void CExample::OnSelchangeCombo1() { // TODO: Add your control notification handler code here CString str ; CComboBox *p; p = (CComboBox*)GetDlgItem(IDC_COMBO1); int index = p->GetCurSel(); p->GetLBText(index,str); GetDlgItem(IDC_EDIT1)->SetWindowText(str);
CString str;
GetDlgItem(IDC_COMB1)->GetWindowText(str);
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
但编辑框显示的内容始终是combo box上一次的内容,也就是慢一拍
void CExample::OnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
CString str ;
CComboBox *p;
p = (CComboBox*)GetDlgItem(IDC_COMBO1);
int index = p->GetCurSel();
p->GetLBText(index,str);
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}