///<summary>Method reads in a ListBox to move items from, and another ListBox to move items into. It checks the first list's selected indices and then, if it ///finds a matching clinic it removes it from the "from" list and moves it to the "to" list.</summary> private List <Clinic> MoveClinics(ListBox listFrom, ListBox listTo) { if (listFrom.SelectedIndices.Count == 0) { return(new List <Clinic>()); //If nothing is selected, change nothing so the UI doesn't refresh. } List <Clinic> listClinicsTo = listTo.AllTags <Clinic>(); List <Clinic> listMoved = new List <Clinic>(); //We go through the listFrom and find the SelectedIndicies. Then, remove them from the listFrom and add them to listTo after. foreach (int index in listFrom.SelectedIndices.AsEnumerable <int>().OrderByDescending(x => x)) { Clinic clinic = ((ODBoxItem <Clinic>)listFrom.Items[index]).Tag; listFrom.Items.RemoveAt(index); listMoved.Add(clinic); } listClinicsTo.AddRange(listMoved); //Set box items again & deselect the listboxes listClinicsTo.Sort(NaturalSort); //Sort Alphabetically listTo.SetItems(listClinicsTo, x => x.Abbr); return(listMoved); }