用VC6.0创建一个CombTest项目对话框,并且从控件工具箱将 Combo Box 控件拖放到上面,
在combo box的属性里的styles->types下选simple,然后把combo box框拉大到你希望的下拉的范围大小,将Sort钩选项去掉,再回到styles->types下选drop down 。复制这个组合框得到16个组合框ID号依次 IDC_COMB1, IDC_COMB1, IDC_COMB3,... IDC_COMB16。
1、在OnInitDialog()函数上面添加全局变量代码
int m_CountGetCurSel[16];//索引号
UINT m_CountComboID[16]=//控件ID号
{
IDC_COMB1,
IDC_COMB2,
IDC_COMB3,
IDC_COMB4,
IDC_COMB5,
IDC_COMB6,
IDC_COMB7,
IDC_COMB8,
IDC_COMB9,
IDC_COMB10,
IDC_COMB11,
IDC_COMB12,
IDC_COMB13,
IDC_COMB14,
IDC_COMB15,
IDC_COMB16,
};
CString COMB_Data[17]={"------","信号1","信号2","信号3","信号4","信号5","信号6","信号7","信号8","信号9","信号10","信号11","信号12","信号13","信号14","信号15","信号16"};
在这里插入代码片
2、在OnInitDialog()函数中添加代码
for (int i=0; i<16; i++)
{
for (int j=0; j<17; j++)
{
((CComboBox*)GetDlgItem(m_CountComboID[i]))->AddString(COMB_Data[j]);
((CComboBox*)GetDlgItem(m_CountComboID[i]))->SetCurSel(0);
}
}
源码下载
https://download.csdn.net/download/weixin_42350092/87697846?spm=1001.2014.3001.5503