MFC两个combobox 第二个下拉列表里的选项会根据第一个combobox选择的项变动,如何实现?
我现在的代码是这样:GetDlgItem(IDC_COMBO1)->EnableWindow(false);category.InsertString(0,"蛋糕");c...
我现在的代码是这样:
GetDlgItem(IDC_COMBO1)->EnableWindow(false);
category.InsertString(0,"蛋糕");
category.InsertString(1,"水果");
category.InsertString(2,"咖啡");
category.InsertString(3,"饼干");
category.InsertString(4,"牛奶");
GetDlgItem(IDC_COMBO1)->EnableWindow(true);
name.ResetContent();
int c=category.GetCurSel();
switch(c)
{
case 0:
name.AddString(_T("黑森林蛋糕"));
name.AddString(_T("慕斯蛋糕"));
break;
case 1:
name.AddString(_T("香蕉"));
name.AddString(_T("草莓"));
break;
case 2:
name.InsertString(0,"康师傅");
name.InsertString(1,"统一");
break;
case 3:
name.InsertString(0,"曲奇饼干");
name.InsertString(1,"梳打饼干");
break;
case 4:
name.InsertString(0,"伊利");
name.InsertString(1,"蒙牛");
break;
default:
name.AddString(_T("木有东西"));
break;
}
可是第二个下拉列表里永远显示“木有东西”,怎么会这样55555 展开
GetDlgItem(IDC_COMBO1)->EnableWindow(false);
category.InsertString(0,"蛋糕");
category.InsertString(1,"水果");
category.InsertString(2,"咖啡");
category.InsertString(3,"饼干");
category.InsertString(4,"牛奶");
GetDlgItem(IDC_COMBO1)->EnableWindow(true);
name.ResetContent();
int c=category.GetCurSel();
switch(c)
{
case 0:
name.AddString(_T("黑森林蛋糕"));
name.AddString(_T("慕斯蛋糕"));
break;
case 1:
name.AddString(_T("香蕉"));
name.AddString(_T("草莓"));
break;
case 2:
name.InsertString(0,"康师傅");
name.InsertString(1,"统一");
break;
case 3:
name.InsertString(0,"曲奇饼干");
name.InsertString(1,"梳打饼干");
break;
case 4:
name.InsertString(0,"伊利");
name.InsertString(1,"蒙牛");
break;
default:
name.AddString(_T("木有东西"));
break;
}
可是第二个下拉列表里永远显示“木有东西”,怎么会这样55555 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询