求教C#中 ComboBox 控件显示问题,问题详见内文,请各位先进帮各忙。
我在windows form中使用两个ComboBox 控件,要产生以下结果:
ComboBox1 ComboBox2
A 1,2,3,4,5,6
B 12,456,789
当ComboBox1为A时,ComboBox2显示 1,2,3,4,5,6等选项,
当ComboBox1为B时,ComboBox2显示 12,456,789等选项,
但是我就是卡在不清楚操作方式,请各相助一下,Thx。
------解决方案--------------------在combobox1的selectChange事件中
if(combobox1.selectIndex)
{
combobox1.item.AddRange(new string[] {"1","2","3","4","5","6"});
}
else
{
combobox1.item.AddRange(new string[] {"12","456","789"});
}
------解决方案--------------------在combobox1的selectChange事件中
if(combobox1.selectIndex==0)
{
combobox1.clear();
combobox1.item.AddRange(new string[] {"1","2","3","4","5","6"});
}
else
{
combobox1.clear();
combobox1.item.AddRange(new string[] {"12","456","789"});
}