//**************************************************************************************************** public static List <CityData> getCityData(string str) { str = str.ToLower(); List <CityData> data = new List <CityData>(); if (cityData == null) { DataTable dt = new ModCity().getSelect(); foreach (DataRow dr in dt.Rows) { CityData item = new CityData() { cityName = dr["cityName"].ToString(), spell = dr["spell"].ToString().ToLower(), firstSpell = dr["firstSpell"].ToString().ToLower() }; data.Add(item); } cityData = data; } else { data = cityData; } return((data.Where( item => (item.cityName.Contains(str)) || (item.spell.Contains(str)) || (item.firstSpell.Contains(str)) )).ToList <CityData>()); }
//**************************************************************************************************** private void cmbCity_KeyUp(object sender, KeyEventArgs e) { if (cmbCity.Text == "") { lstCity.Visible = false; } else { List <CityData> cityData = CityData.getCityData(cmbCity.Text); if (cityData == null) { lstCity.Visible = false; } else { lstCity.Visible = true; lstCity.DataSource = cityData; lstCity.DisplayMember = "cityName"; lstCity.ValueMember = "cityName"; } } }