473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

drag / drop list view items from two list views

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
3 3513
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Guarnieri | last post by:
Hi All, I need some code to drag items in a list box either up or down along with not just the text but with the itemdata too. Can anyone hook me up? TIA John
2
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put...
3
by: Ajay Krishnan Thampi | last post by:
I have a slight problem implementing 'drag and drop' from a datagrid to a tree-view. I have pasted my code below. Someone please advice me on what to do...pretty blur right now. ==code== ...
7
by: Sam | last post by:
Hi, I've done the method described here : http://64.78.52.104/FAQ/WinForms/FAQ_c87c.asp#q565q It works well for items added at design time. However if my source list is filled with a...
3
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
3
by: JL | last post by:
I have found may examples for dragging and dropping between list boxes but I need to do it within one. Can some one point me to a tutorial or example. Prefer VB but can use C# too. TIA, John
1
by: Alan T | last post by:
I have a tree view on the left and a list view on the right. I will drag and drop from list view to treeview, and also drag drop tree node on the same tree view. How do I differentiate I drag...
1
by: Sim | last post by:
Hello NG, I try to use drag and drop function between two list views. For this I found following code: ...
2
by: anchi.chen | last post by:
Hi People, Just wondering if any of you have ever come across any javascript examples that will allow one to drag and drop multiple items between lists? That is, users would be able to use the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.