Hi,
Well, The below code does work for a DataTable, I bet it will work for a
listview as you will have the exact same issues.
The problem is that you cannot do this:
foreach(ListViewItem item in listview.SelectedItem)
listview.Items.Delete( item );
cause you are modifying the collection and iterating at the same time ( an
exception will be throw IIRC ).
Solution:
Use a temp list
ArrayList elems = new ArrayList()
foreach(ListViewItem item in listview.SelectedItem)
elems.Add( item );
foreach(ListViewItem item in elems)
listview.Items.Delete( item );
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Visual Systems AB (Martin Arvidsson)" <ma**************@vsab.net> wrote in
message news:OQ**************@TK2MSFTNGP10.phx.gbl...
Hi!
I'v been struggeling with removing selected items from a listview.
Anyone that can give me a piece of code that does this?
I am a newbee to this C# and cant figure it out....
Regards
Martin Arvidsson