By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,166 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,166 IT Pros & Developers. It's quick & easy.

drag / drop list view items from two list views

P: n/a
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!
Mar 22 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
The ListViewItem.Clone method works just fine in both 2003 and 2005. It
doesn't copy the parent/owner

/claes

"Brian Henry" <no****@nospam.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
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!

Mar 22 '06 #2

P: n/a
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
"Claes Bergefall" <cl*************@nospam.nospam> wrote in message
news:ed**************@TK2MSFTNGP12.phx.gbl...
The ListViewItem.Clone method works just fine in both 2003 and 2005. It
doesn't copy the parent/owner

/claes

"Brian Henry" <no****@nospam.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
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!


Mar 22 '06 #3

P: n/a
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
"Brian Henry" <no****@nospam.com> wrote in message
news:ee**************@TK2MSFTNGP11.phx.gbl...
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
"Claes Bergefall" <cl*************@nospam.nospam> wrote in message
news:ed**************@TK2MSFTNGP12.phx.gbl...
The ListViewItem.Clone method works just fine in both 2003 and 2005. It
doesn't copy the parent/owner

/claes

"Brian Henry" <no****@nospam.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
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!



Mar 23 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.