Reinstating removed listview rows

DiverDan

Contributor
Joined
Jan 16, 2003
Messages
645
Location
Sacramento, CA
Once a row or multipule rows are removed from the listview how can they be reinststed with undo?

Here's what I have so far...

Case "Clear &Row"
Try
btnUndo.ImageIndex = 19
Dim i As ListViewItem
Dim myDataObject As New DataObject()
For Each i In lvwData.SelectedItems
myDataObject.SetData(DataFormats.Text, True, lvwData.SelectedItems)
Clipboard.SetDataObject(myDataObject, True)
lvwData.Items.Remove(lvwData.SelectedItems(0))
Next
Catch
End Try
 
You could try adding the ListViewItems themselves in to an undo stack (use the System.Collections.Stack class) when you remove them. When you undo, simply pop the item back off the stack and re-add it to the list.
 
Back
Top