private void RemovePlatformBase(PlatformData platform) { List <ListViewItem> toremove = new List <ListViewItem>(); foreach (ListViewItem songitem in SongList.Items) { SongListItem songtag = songitem.Tag as SongListItem; List <FormatData> ftoremove = new List <FormatData>(); foreach (FormatData data in songtag.Data) { if (data.PlatformData == platform) { ftoremove.Add(data); } } if (ftoremove.Count > 0) { toremove.Add(songitem); } foreach (FormatData data in ftoremove) { songtag.RemoveData(data); } } foreach (ListViewItem item in toremove) { SongList.Items.Remove(item); } }