国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#中comboBox實現三級聯動

2019-10-29 21:05:01
字體:
來源:轉載
供稿:網友

實現效果:

C#,comboBox,三級聯動

Form1.cs代碼

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Collections;namespace Select{ public partial class Form1 : Form { public Form1() {  InitializeComponent(); } Hashtable province = new Hashtable(); Hashtable city = new Hashtable(); private void Province() {  province.Add("云南省",new string[] {"昆明市","玉溪市" });  province.Add("四川省", new string[] { "成都市", "綿陽市" });  city.Add("昆明市",new string[] {"盤龍區","五華區" });  city.Add("玉溪市",new string[] {"紅塔區","。。。區" });  city.Add("成都市", new string[] { "。。。區", "。。。區" });  city.Add("綿陽市", new string[] { "...區", "...區" }); } private void Form1_Load(object sender, EventArgs e) {  Province();  foreach (string str in province.Keys)  {  comboBox1.Items.Add(str);  }  foreach (string str in city.Keys)  {  comboBox2.Items.Add(str);  }  comboBox1.SelectedIndex=0; } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) {  string[] citys = province[comboBox1.Text] as string[];  comboBox2.Items.Clear();  foreach (string s in citys)  {  comboBox2.Items.Add(s);  }   comboBox2.SelectedIndex = 0; } private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) {  string[] citys = city[comboBox2.Text] as string[];  comboBox3.Items.Clear();  foreach (string str in citys)  {  comboBox3.Items.Add(str);  }  comboBox3.SelectedIndex = 0; } private void comboBox3_SelectedIndexChanged(object sender, EventArgs e) { } }}

更多相關的實現方法大家可以閱讀下面的相關內容,感謝大家對VEVB武林網的支持。

本文轉載于:https://www.idaobin.com/archives/970.html


注:相關教程知識閱讀請移步到c#教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 澄江县| 新郑市| 揭东县| 化德县| 武宣县| 枣阳市| 壶关县| 孟州市| 昆山市| 宁德市| 苍南县| 东宁县| 永清县| 凤山县| 尤溪县| 平阴县| 英超| 滕州市| 威远县| 鸡东县| 上蔡县| 闽侯县| 水城县| 石林| 木兰县| 韶山市| 江孜县| 库尔勒市| 灌云县| 建始县| 奈曼旗| 万荣县| 河曲县| 许昌市| 区。| 鄂尔多斯市| 苗栗县| 隆安县| 青岛市| 阿巴嘎旗| 紫云|