Combox(层)级联(动)显示
本文用于记录在有两个Combox控件时,cbxParent选择项发生变化时,cbxChild跟着改变。
Dictionary<string, string[]> dictParentAndChild = new Dictionary<string, string[]>() {
{"0",new string[]{"0-0","0-1","0-2","0-3"} },
{"1",new string[]{"1-0","1-1","1-2","1-3"}},
{"2",new string[]{"2-0","2-1","2-2","2-3"}},
{"3",new string[]{"3-0","3-1","3-2","3-3"}},
{"4",new string[]{"4-0","4-1","4-2","4-3"}}
};
int index = cbxParent.SelectedIndex;
if (index < 0)
{
return;
}
string strChildName = dictParentAndChild.Items[index].ToString();
string[] arrChild;
dictParentAndChild.TryGetValue(strChildName,out arrChild);
cbxChild.DataSource = arrChild;

浙公网安备 33010602011771号