A simple example realization method of the drop box linkage in province cities

Source: Internet
Author: User

The effect is as follows

//Defining Dictionariesdictionary<string,string> Address =Newdictionary<string,string>(); voidLoadData () {//This is the data you want to add//you can also choose to add dynamically, but considering that the data is not much, it does not affect performance.Address.add ("Mianyang","Sichuan"); Address.add ("Chengdu","Sichuan"); Address.add ("Guanghan","Sichuan"); Address.add ("Nanjing","Jiangsu"); Address.add ("Yangzhou","Jiangsu"); Address.add ("Wuxi","Jiangsu"); Address.add ("Zhuhai","Guangzhou"); Address.add ("Dongguan","Guangzhou"); Address.add ("Shenzhen","Guangzhou"); Address.add ("Shanghai","Municipalities"); //add to the Capital drop-down box by loop value            foreach(stringProvinceinchaddress.values) {//avoid repeated additions to the provincial capital name                if(!ComboBoxEdit1.Properties.Items.Contains (province)) ComboBoxEdit1.Properties.Items.Add (province); }//provincial capital drop-down box select Index MethodPrivate voidComboboxedit1_selectedindexchanged (Objectsender, EventArgs e) {            //Empty the City drop-down box to avoid appending data before adding//you can also choose to add them dynamicallycomboBoxEdit2.Properties.Items.Clear (); //find key values by value            foreach(keyvaluepair<string,string> kvpinchAddress) {                if(KVP. Value.equals (ComboBoxEdit1.SelectedItem.ToString ())) {ComboBoxEdit2.Properties.Items.Ad D (KVP.                Key); }            }                }        

A simple example realization method of the drop box linkage in province cities

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.