private void SetCountryBox() { try { using (GSB_CEEntities dtb = new GSB_CEEntities()) { List <string> ListCountry = new List <string>(); //dtb.Customers.ToList(); ListCountry = dtb.Customers.Select(xn => xn.Country).Distinct().ToList(); comboBox1.DataSource = ListCountry; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void SetCityBox() { using (GSB_CEEntities dtb = new GSB_CEEntities()) { List <string> ListCity = new List <string>(); string FP = comboBox1.SelectedValue.ToString(); var helpme = dtb.Customers.Select(xn => new { xn.City, xn.Country }).Distinct(); foreach (var h in helpme) // textBox1.Text += " Vile=" + h.City.ToString(); { if (h.Country == FP) { ListCity.Add(h.City); } } comboBox2.DataSource = ListCity; } }