I have two value lists when first one is selected, the other one is loaded without selected element. When I try to remove selectedListItem nothing happens? It looks like list doesn’t recognize that it contains that item?
private void laodList(UltraGridRow row, ValueListItem selectedListItem)
{
ValueList elementList = (ValueList)row.Cells["Element"].ValueListResolved;
//clone list
ValueList minMaxList = elementList.Clone();
//remove selected element
minMaxList.ValueListItems.Remove(selectedListItem);
row.Cells["MinElement"].ValueList = minMaxList;
}
minMaxList.ValueListItems.Remove(selectedListItem);This code doesn't work because selectedListItem is a ValueListItem in the original list. It does not get removed, because it doesn't exist in the cloned list. The cloned list contains a cloned item with the same values as selectedListItem, but it's not the same item.
I had to find it firts and then delete worked.
ValueListItem
if ( itemToRemove != null )
minMaxList.ValueListItems.Remove(itemToRemove);