473,651 Members | 2,630 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to copy one listview to another. Hopefully this can help someone ;-)

Hi guys,
I stuffed around with this for a whole day, searching the groups
and trying different methods. So when I finally came up with a solution
I thought I would share it, as it could save someone all the stuffing
round I had to do. Now I don't know if this will solve everyone's
listview copy situation, but it worked for me.

Here is the code:

ListViewItems[] LVIARRY_CopiedL istViewItems = new
ListViewItems[LV_FirstListVie w.Items.Count];

for (int INT_Count=0; INT_Count < LVIARRY_CopiedL istViewItems.Le ngth;
INT_Count++)
{
LVIARRY_CopiedL istViewItems[INT_Count] =
(ListViewItem)L V_FirstListView .Items[INT_Count].Clone();
}

LV_SecondListVi ew.Items.AddRan ge(LVIARRY_Copi edListViewItems );

Scott.

Nov 17 '05 #1
2 4627
did you try the Array.Copy() method work on this? Or does this create
a new instance of an array with references to the original ListItems?

Nov 17 '05 #2
James,
I did try that method, but I had the same problem as the poster
called "CaffeineRu sh" in this post:
---------------------------------------------------
http://groups.google.com/group/micro...294ffc72f62442

I go the same:
---------------------------------------------------
System.Argument Exception error in system.windows. forms.dll:

Additional information: Cannot add or insert the item 'filename.jpg' in
more than one place. You must first remove it from its current location
or clone it.
---------------------------------------------------
After a bit more research I then found this thread:
---------------------------------------------------
http://groups.google.com/group/micro...otnet.*&rnum=2

See where the poster "laurmo" says:
---------------------------------------------------
Basically it then turns out that the ListViewItemCol lection is then
just a reference to the ListView.Items data and any operation done on
one is
reflected on the other.
---------------------------------------------------

I am open to new ideas however?

Scott.

ja*********@gma il.com wrote:
did you try the Array.Copy() method work on this? Or does this create
a new instance of an array with references to the original ListItems?


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1965
by: MikeY | last post by:
Hopefully someone can help, I have a listview box where I display my desired files. I single click on the desired file to be renamed and I rename it with a new name. My problem arises when the new name gets displayed through refreshing of my loop and display function. The problem is that when, if I rename the last file entry, everything appears to display fine. If I rename a file above the last entry (bottom entry), two of the new file...
3
9296
by: MikeY | last post by:
Hopefully someone can help me on this. I am using C#, making Windows forms. I have created a listView with checkbox's. I have enabled the checkboxes under the properties, and all the data, checkbox's and icons are displayed as they are meant to be. My problem is this, I am trying to achieve the same results as I get with CheckListBox(s), where I am able to select (Check-mark) various checkboxs items and able to alter the data. I do...
1
3791
by: MikeY | last post by:
Hopefully someone can help, I have a listview box where I display my desired files. I single click on the desired file to be renamed and I rename it with a new name. My problem arises when the new name gets displayed through refreshing of my loop and display function. The problem is that when, if I rename the last file entry, everything appears to display fine. If I rename a file above the last entry (bottom entry), two of the new file...
9
3041
by: Devron Blatchford | last post by:
Hi there, Just wondering if I change the back and fore colour of a listview item when the mouse hovers over it? I want to overide the default windows colour. Can someone please tell me how to do this? Thanks Devron
6
9967
by: Beginner | last post by:
Hi, I'm trying to populate a TreeView from an existing and filled in ListView (lvwBuild). lvwBuild is a basic two column listview which can have any number of rows. I would like the first column of lvwBuild to be a node and the second column to be a branch on the TreeView (hopefully I have the syntax correct). I've been researching how to do this but have come up empty. I'm guessing that you would fill an array from lvwBuild and...
2
2486
by: Tim.Geiges | last post by:
This seems like ti should be very simple but I am sort of a newb and this one is killing me I am just trying to copy all the items that are checked in listView2 over to listView1 when a button is clicked. can anyone give me an example please? Thank you for your time, Tim
4
10803
by: Pucca | last post by:
How can I tell a mouse right clicks over a listview item that's in a container panel. I only want to display a popup menu if the user right click the mouse over an item on the Listview. I don't not want to display this menu if a node selected on the listview but user right click over the empty space of the panel that contain the listview. The problem here is when I use the Listview's Click Event, I don't have ways to verify if the...
1
2662
by: MikeY | last post by:
Hi Everyone, I am trying to ensure displayed items at the top most portion of my ListView when being added to my ListView, no matter where the items are being added with in the listview. So that the users can easily find where their added items are located. Can this be accompished with "TopItem"??? My code is as follows: foreach(ListViewItem ListView_Item in this.lvBody.Items) {
1
5418
by: BeckyBair | last post by:
Currently I have a program form that has 2 listviews on it. It is able to copy one item from one listview to another. Now the users want to be able to copy several at once from one listview and paste into the other at point/row where they click/selected. I hope that makes sense. Here is what I have currently for the single copy/paste type of process: Private Sub cmdSetSeqNum_Click() Dim ItmX As ListItem On Error GoTo ERR_HNDL...
0
8349
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8795
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8695
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8460
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7296
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6157
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
1906
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1585
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.