private void SettingsUI_Load(object sender, EventArgs e) { using (var context = new UpdateJinnyDBEntities()) { var countries = context.TableCityByCountries.Select(c => c.country).Distinct().ToList(); comboBoxCountries.Items.AddRange(countries.ToArray()); } }
private void comboBoxCountries_SelectedIndexChanged(object sender, EventArgs e) { using (var context = new UpdateJinnyDBEntities()) { var rr = context.TableCityByCountries.Where(m => m.country == comboBoxCountries.Text).Select(c => c.city); comboBoxCities.Items.Clear(); comboBoxCities.Items.AddRange(rr.ToArray()); } }