When I remove Items with objectListViewInstance.Items.Clear(), Objects will just disappear visually as Items, but they are still in objectListViewInstance.Objects collection.
When I try
foreach(object o in objectListViewInstance.Objects)
{
objectListViewInstance.RemoveObject(o);
}
it ends up with NullPointerException.
Is there any way to remove Objects since there isn't any Objects.Clear() method?
According to comments I tried to do
objectListViewInstance.Objects = null;
and it just works fine :)
Is there any way to remove Objects since there isn't any Objects.Clear() method?
The intended methods are
objectListViewInstance.ClearObjects();
to clear all objects and
objectListViewInstance.RemoveObject(o);
to remove a specific model object. However, as Sriram pointed out in the comments, don't remove items from a collection while iterating over it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With