Wednesday 15 February 2012

.net - How to delete all items from a group in ListView component c# -


I am trying to delete all the items from a ListViewGroup in a ListView component (C # .NET 4.0). I have tried to do the following things, but they return unexpected behavior.

  listView1.Groups [4] .imes. Cleaner (); // Is the item removed from the group only, // then a new default group is placed in the forehatch (list item item list in the list 1. group [4] .ms) {item.Remove (); } // It throws an error that says the list has changed.   

Now I listView1.Items.Clear (); I am using all the items in the group to clean, and read them one by one. However this is due to my GUI flicker when this action takes place. I want to know how to remove all items in a group. So that I only have to add the item group again (which I want because the number of items is different and the names and the sub-categories are different).

Note: The group is called lvgChannels and has an index 4.

Try it out:

  list & lt; ListViewItem & gt; Remove = new list & lt; ListViewItem & gt; (); Forehatch (List view list items in list 1. Groups [4] .ms) {remove.Add (item); } Foreach (See item items in list) {listView1.Items.Remove (item); }}   

The problem with your second statement is that you remove that item from the list that you are running again.

No comments:

Post a Comment