How to enumerate a ListView when it is in virtual mode ?
I’m using OfType<>() method to enumerate the list view items. But its throwing an exception like, the list view can not be enumerated when it is in virtual mode.
Here is my code
List<String> lst= myListView.Items.OfType<ListViewItem>().Select(X=>X.Text).ToList();
So how do i get the item from the ListView when it is in Virtual mode?
Please post me a way to use .OfType<>
Thanks in advance
When it’s in virtual mode you can’t get the items out of the list view because the items aren’t in the list view. That’s the whole point of virtual mode.
Instead, you hold the items and the list view asks for the information it needs to display the items. If you are operating a list view successfully in virtual mode then you almost certainly already have the items in a list somewhere.
Quoting from the documentation: