c++中,用mfc做界面,组合框和编辑框的问题

2025-02-25 23:47:46
推荐回答(2个)
回答1:

设置组合框的选项 两种方法 第一在资源编辑 属性中 添加

用代码的方法 先用类向导 给combo控件关联 CComboBox类型变量

在对话框的OnInitDialog()中

用代码来添加 

比如

m_combo.AddString(_T("1"));

m_combo.AddString(_T("2"));

m_combo.AddString(_T("3"));


给combo控件添加CBN_SELCHANGE消息响应函数

void CMfcdlgDlg::OnSelchangeCombo1() 

{

// TODO: Add your control notification handler code here

CString s;

m_combo.GetLBText(m_combo.GetCurSel(), s);

if(s=="1")

{

SetDlgItemText(IDC_EDIT1, "a");

}

if(s=="2")

{

SetDlgItemText(IDC_EDIT1, "b");

}

if(s=="3")

{

SetDlgItemText(IDC_EDIT1, "c");

}

}

回答2:

如果是VC6,可以给你个例子。