Home All Groups Group Topic Archive Search About

drag / drop list view items from two list views

Author
22 Mar 2006 3:26 PM
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!

Author
22 Mar 2006 5:45 PM
Claes Bergefall
The ListViewItem.Clone method works just fine in both 2003 and 2005. It
doesn't copy the parent/owner

   /claes

Show quoteHide quote
"Brian Henry" <nospam@nospam.com> wrote in message
news:eNaPNUcTGHA.4264@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!
>
Author
22 Mar 2006 6:32 PM
Brian Henry
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


Show quoteHide quote
"Claes Bergefall" <claes.bergefall@nospam.nospam> wrote in message
news:eddI3gdTGHA.4452@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" <nospam@nospam.com> wrote in message
> news:eNaPNUcTGHA.4264@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!
>>
>
>
Author
23 Mar 2006 4:24 PM
Claes Bergefall
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


Show quoteHide quote
"Brian Henry" <nospam@nospam.com> wrote in message
news:eerB07dTGHA.4264@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" <claes.bergefall@nospam.nospam> wrote in message
> news:eddI3gdTGHA.4452@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" <nospam@nospam.com> wrote in message
>> news:eNaPNUcTGHA.4264@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!
>>>
>>
>>
>
>