当我选中组合框中的一项时,想在另外一个静态文本框显示它的名字怎么搞?
例如:一个Education组合框有三个选择条目college,Grad School,High School;
当我选中college时在旁边的静态文本中显示出college怎么搞?谢谢

解决方案 »

  1.   

    当我选中college时在旁边的静态文本中显示出college怎么搞?
    ====================
    是指鼠标在上面移动时,还没有单击时产生的消息吗?
      

  2.   

    哦,好办,在类向导中响应CBN_SELENDOK消息就可以
      

  3.   

    ON_CBN_SELENDOK   The user selects an item and then either presses the ENTER key or clicks the DOWN ARROW key to hide the list box of a combo box. This notification message is sent before the CBN_CLOSEUP message to indicate that the user’s selection should be considered valid. The CBN_SELENDCANCEL or CBN_SELENDOK notification message is sent even if the CBN_CLOSEUP notification message is not sent (as in the case of a combo box with the CBS_SIMPLE style).ON_CBN_SELCHANGE   The selection in the list box of a combo box is about to be changed as a result of the user either clicking in the list box or changing the selection by using the arrow keys. When processing this message, the text in the edit control of the combo box can only be retrieved via GetLBText or another similar function. GetWindowText cannot be used.响应消息后 给你的静态文本SetWindowText就可以了
      

  4.   

    然后在你不是要在另外一个静态文本框显示它的名字吗,首先你要通过函数GetCurSel和GetLBText获得当前选中的条目(college)的字符串,即CString str;str="college";了.最后就是要把这个str显示在静态文本框里面,假设静态文本框的ID为ID_IIII;则可以
    GetDlgItem(ID_IIII)->SetWindowText(str);UpdateData(FALSE);就可以显示了
      

  5.   

    可能是我表述不准确的问题
    我是说如果在组合框中显示的是college,其他两项在下拉菜单中
    这时在另外一个静态文本框中显示的名字是college
    如果显示的是High School
    则在静态文本框中显示的名字是High School
      

  6.   

    我是说如果在组合框中显示的是college,其他两项在下拉菜单中
    =====================================================
    college,Grad School,High School不是有三个吗,怎么只有两项在下拉框中了?
      

  7.   

    如你的edit的CString变量定义为m_edit,你的COMBO1的CComboBox的变量定义为这个m_combo1的话,就如下:
    m_combo1.GetWindowText(m_edit);
    UpdateData(false);
    就可以了,不知道是不是你想要的,别忘了,UpdateData(false);这句。
      

  8.   

    在CBN_SELENDOK的消息实现函数中加入下面代码:m_ctrlBaud是你的组合框控件变量,IDC_STATICTEXT是静态文本框ID,
    int i=m_ctrlBaud.GetCurSel();//找到当前索引号
    CString rString;
    m_ctrlBaud.GetLBText(i, rString);//得到对应索引号的文本
    GetDlgItem(IDC_STATICTEXT)->SetWindowText(rString);//文本在静态文本框显示出来
    UpdateData(FALSE);
    这样就行了