void OnCheckedItemsChanged(object sender, ListChangedEventArgs e) { foreach (string item in CheckedItems) { if (CurveList.IndexOfTag(item) < 0) { AddItem(item); } } List <string> itemsToRemove = new List <string>(); foreach (LogGraphCurveItem item in CurveList) { if (!CheckedItems.Contains(item.ItemID)) { itemsToRemove.Add(item.ItemID); } } foreach (string item in itemsToRemove) { RemoveItem(item); } }