private void btnAddSelected_Click(object sender, EventArgs e) { List <Item> ret = new List <Item>(); foreach (object obj in lbResult.SelectedItems) { string search = lbResult.GetItemText(obj); foreach (Item i in this.items) { if (search == i.ToString()) { ret.Add(i); break; } } } try { itemRepo.AddToCSV(ret); } catch (Exception ex) { MessageBox.Show(ex.Message); } this.Close(); }