private void LoadCustomerToList() { TrainingEntities db = new TrainingEntities(); foreach (var item in db.Customers) { listBoxCustomer.Items.Add(item.name); } }
private void buttonSearch_Click(object sender, EventArgs e) { TrainingEntities db = new TrainingEntities(); listBoxCustomer.Items.Clear(); var searchResult = db.Customers.Where(c => c.name.Contains(txtName.Text)); foreach (var item in searchResult) { listBoxCustomer.Items.Add(item.name); } }