ComboxEdit实现二级联动

时间:2021-03-17 05:55:10
 private void cmbXPROVINCE_SelectedIndexChanged(object sender, EventArgs e)
{
DataBind(cmbXPROVINCE, cmbXROAD);
} /// <summary>
/// 实现省、市
/// </summary>
/// <param name="cmbFirst">一级(区市)</param>
/// <param name="cmbSecond">二级(街道)</param>
public void DataBind(ComboBoxEdit cmbFirst, ComboBoxEdit cmbSecond)
{
switch (cmbFirst.Text.Trim())
{
case "河南省":
cmbSecond.Properties.Items.Clear();
cmbSecond.Text = "";
cmbSecond.Properties.Items.Add("郑州市");
cmbSecond.Properties.Items.Add("开封市");
cmbSecond.Properties.Items.Add("驻马店市");
cmbSecond.Properties.Items.Add("安阳市");
cmbSecond.Properties.Items.Add("洛阳市");
cmbSecond.Properties.Items.Add("周口市"); break; case "河北省":
cmbSecond.Properties.Items.Clear();
cmbSecond.Text = "";
cmbSecond.Properties.Items.Add("保定");
cmbSecond.Properties.Items.Add("石家庄");
cmbSecond.Properties.Items.Add("邯郸");
break;
//.......... default:
break;
}
}