本文介绍了我是国家,州和城市的3个组合框.当我选择一个将在第二个组合框中显示核心州的国家时,当我选择一个将在第二个组合框中显示州的城市时...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为国家,州和城市设置了3个组合框.当我选择一个核心国家将在第二个组合框中显示的国家时,当我选择一个核心城市将在第三个组合框中显示的国家时,请给我c#代码.without数据库不使用Windows application

i''he 3 combobox for country,state and cities.when i select one country that coressponing states will display in 2nd combobox,and when i select one state that coressponing cities will display in 3rd combobox .give me the c# code .without database using windows application

推荐答案

//Create a BindingSource for Country ComboBox using Country table from DataSet1
BindingSource CountryBindingSource = New BindingSource(DataSet1, "Country");
//Now create a BindingSource with CountryBindingSource as the parent using the relation 
BindingSource StateBindingSource = New BindingSource(CountryBindingSource, "CountryState");
//Then create a BindingSource with StateBindingSource as the parent using the relation 
BindingSource CityBindingSource = New BindingSource(StateBindingSource, "StateCity");

//Set the DataSource, DisplayMember and ValueMember properties of the ComboBoxes as below
comboBox1.DataSource = CountryBindingSource;
comboBox1.DisplayMember = "Country";
comboBox1.ValueMember = "CountryID";
comboBox2.DataSource = StateBindingSource;
comboBox2.DisplayMember = "State";
comboBox2.ValueMember = "StateID";
comboBox3.DataSource = CityBindingSource;
comboBox3.DisplayMember = "City";
comboBox3.ValueMember = "CityID";



这篇关于我是国家,州和城市的3个组合框.当我选择一个将在第二个组合框中显示核心州的国家时,当我选择一个将在第二个组合框中显示州的城市时...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:12
查看更多