我的软件里用了CComboBox类,我想在添加了一个条目后,此条目直接显示在edit框中,请问用那个函数?
styles为droplist.下面的代码只把条目加在了下啦列表中
void CPlayerDlg::OnButtonAdd() 
{
  CUserDlg userdlg;
  if (userdlg.DoModal()==IDOK)
  {
UpdateData(TRUE);
CString codename;
codename=userdlg.m_usercode+userdlg.m_username;
    m_combouser.AddString(codename); UpdateData(FALSE);
//codename.Empty();  }

解决方案 »

  1.   

    int SetCurSel( int nSelect );
      

  2.   

    msdn:
    CComboBox::SetCurSel
    int SetCurSel( int nSelect );Return ValueThe zero-based index of the item selected if the message is successful. The return value is CB_ERR if nSelect is greater than the number of items in the list or if nSelect is set to –1, which clears the selection.ParametersnSelectSpecifies the zero-based index of the string to select. If –1, any current selection in the list box is removed and the edit control is cleared.ResSelects a string in the list box of a combo box. If necessary, the list box scrolls the string into view (if the list box is visible). The text in the edit control of the combo box is changed to reflect the new selection. Any previous selection in the list box is removed.Example// The pointer to my combo box.
    extern CComboBox* pmyComboBox;// Select the last item in the combo box.
    int nCount = pmyComboBox->GetCount();
    if (nCount > 0)
       pmyComboBox->SetCurSel(nCount-1);
      

  3.   

    最简单的:
    定义一个中间字符串变量,把Add到ComboBox里的字符串同时写进中间串,然后再把中间串写Add到Edit
    这是想都不用想就冒出来的超弱智办法