Re: Efficient way of removing selected items from a (very) large ListView
- From: "JerryWEC" <JerryWEC@xxxxxxxxxxxxxxxxx>
- Date: Wed, 17 Jan 2007 18:11:45 -0500
Bry, I don't personally know of a way in c# to cycle thru a collection
backwards (but you should be able to do it). (In VB6 [maybe vb.net] you have
a Step -1 so you can decrement backwards) Don't think this will work with a
collection.
Idea: You might be able to cycle (foreach) thru the lv.SelectedIndices
collection and assign the index values to an integer array and then use a
regular for loop and decrement loop control variable.
foreach (int index in lv.SelectedIndices)
{
intArray.Add(index); /* ArrayList or int array ???*/
}
int max = lv.SelectedIndices.count; (or intArray.Count)
for(i = max, 0, i--)
{
lv.Items.RemoveAt(intArray(i)); // Might have to convert object to
int if you use an array list and not a int array.
}
It has been a long time since I really tried to write some C/C++/C# code and
not sure if the syntax of the loop is correct but you get the idea.
Removing the item in reverse order as you suggest would / should only effect
the items at the end of the list and perserve the lower indexed items.
Please let me know if this works.
JerryM
.
- References:
- Prev by Date: Re: DataGrid Hierarchical Data view display in Windows Form
- Next by Date: Re: Charts Control
- Previous by thread: Efficient way of removing selected items from a (very) large ListView
- Next by thread: Re: Efficient way of removing selected items from a (very) large ListView
- Index(es):
Relevant Pages
|