實現(xiàn)效果:
專注于為中小企業(yè)提供成都網(wǎng)站建設(shè)、成都做網(wǎng)站服務(wù),電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)東明免費做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了1000+企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實現(xiàn)規(guī)模擴充和轉(zhuǎn)變。
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[] {"盤龍區(qū)","五華區(qū)" }); city.Add("玉溪市",new string[] {"紅塔區(qū)","。。。區(qū)" }); city.Add("成都市", new string[] { "。。。區(qū)", "。。。區(qū)" }); city.Add("綿陽市", new string[] { "...區(qū)", "...區(qū)" }); } 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) { } } }
更多相關(guān)的實現(xiàn)方法大家可以閱讀下面的相關(guān)內(nèi)容,感謝大家對創(chuàng)新互聯(lián)的支持。
本文轉(zhuǎn)載于:https://www.idaobin.com/archives/970.html