已省、市下拉框级联关系作为例子
private void Form1_Load(object sender, EventArgs e)
{
ComPro.DataSource = new string[] { "河南", "山东", "安徽" };
}
private void ComPro_SelectedIndexChanged(object sender, EventArgs e)
{
string[][] cityStr = { new string[]{ "商丘", "郑州", "开封" }, new string[]{ "菏泽", "威海", "青岛" }, new string[]{ "合肥", "亳州", "徐州" } };
switch (ComPro.SelectedIndex)
{
case 1:
comCity.DataSource = cityStr[ComPro.SelectedIndex];
break;
case 2:
comCity.DataSource = cityStr[ComPro.SelectedIndex];
break;
case 3:
comCity.DataSource = cityStr[ComPro.SelectedIndex];
break;
}
网友评论