Search code examples
c#listviewobjectlistview

ObjectListView - how to remove all objects


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?


Solution

  • According to comments I tried to do

    objectListViewInstance.Objects = null;
    

    and it just works fine :)