/*递归方法*/ private void BindArea(string cityNo, int level, string pre) { List<AreaTInfo> cityList = new List<AreaTInfo>(); foreach (AreaTInfo item in areaList) { if (item.F_AreaSN==cityNo.Trim()) { cityList.Add(item); } } string preStr = string.Empty; if (level > 0) { preStr +=pre+ "|"; for (int i = 0; i < 2; i++) { preStr += "-"; } } int newye = level + 1; foreach (AreaTInfo item in cityList) { this.cmb_Area.Items.Add(preStr+new AreaInfo(item.AreaSN,item.AreaName).ToString()); dic.Add(item.AreaSN,preStr+new AreaInfo(item.AreaSN,item.AreaName).ToString()); BindArea(item.AreaSN, newye, preStr); } } Dictionary<string, string> dic = new Dictionary<string, string>(); string _areaSN = string.Empty; /*ComboBox SelectedIndexChanged 事件*/ private void cmb_Area_SelectedIndexChanged(object sender, EventArgs e) { string tmp = this.cmb_Area.SelectedItem.ToString(); /*遍历Dictionary<string,string>*/ foreach (KeyValuePair<string,string> item in dic) { if (item.Value==tmp) { _areaSN = item.Key; } } }递归绑定ComboBox

相关文章:

  • 2021-11-24
  • 2021-12-19
  • 2021-11-11
  • 2021-10-14
  • 2021-08-16
  • 2021-05-23
猜你喜欢
  • 2021-08-08
  • 2021-06-02
  • 2021-11-16
  • 2021-11-16
  • 2021-12-09
  • 2021-08-11
  • 2021-11-06
相关资源
相似解决方案