drag / drop list view items from two list views

  • Thread starter Thread starter Brian Henry
  • Start date Start date
B

Brian Henry

So what is the easiest way to do this? I have one list view with a list of
items (in detail view and with about 20 sub items) and a second list view
that will take the items they drag from the first one to the second one. I
tried this once a few years ago by trying to clone the list view item so i
didnt have to recreate it, but ran into the problem of the item already had
a parent... i dont want to remove the items from the first list when they
are dragged... what is the easiest way to "clone" a list view item from one
list to another? or do i have to manually create a new list view item on
drop to add to the new list and manually reset all those subitems... which
is tedious... thanks!
 
The ListViewItem.Clone method works just fine in both 2003 and 2005. It
doesn't copy the parent/owner

/claes
 
wierd... it says that for me... throws an exception and says the item
already blongs to another parent... this is in VS 2005... had the same thing
happen in a different program in VS.NET 2003
 
That is strange indeed. I used the following code to test the behaviour of
Clone and it works perfectly

For Each item As ListViewItem In ListView1.SelectedItems
Dim newItem As ListViewItem = CType(item.Clone(), ListViewItem)
ListView2.Items.Add(newItem)
Next

This is invoked from a button click event handler

/claes
 
Back
Top