ComBo Box 基本属性:
Data: 添加数据 使用;进行数据之间的分割
Type:DropDown:可以进行修改 ,Drop List 不能修改
Sort :是否自动排序
下面使用代码进行下拉框的修改:
添加一个下拉框 对其添加变量,完成之后再初始化的地方 进行编写:
//对下拉框进行添加
m_combox.AddString(TEXT("5"));
m_combox.AddString(TEXT("1"));
m_combox.AddString(TEXT("2"));
m_combox.AddString(TEXT("3"));
////设置默认显示哪一个
m_combox.SetCurSel(2);
////插入值
m_combox.InsertString(1,TEXT("4"));
//获取值
CString str1;
m_combox.GetLBText(2,str1);
//删除值
m_combox.DeleteString(2);//获取某个索引
int index = m_combox.GetCurSel();
CString str2;
m_combox.GetLBText(index,str2);
MessageBox((str1));
当值变化时会触发一个事件,右键属性 进行添加触发事件
void CComboBoxDlg::OnCbnSelchangeCombo1()
{
// TODO: 在此添加控件通知处理程序代码
//获取某个索引
int index = m_combox.GetCurSel();
CString str2;
m_combox.GetLBText(index, str2);
MessageBox((str2));
}