473,569 Members | 2,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copy Listview to Listview

I have two Listview controls on the stage:
lv_Files
lv_SelectedFile s

I have a function that copies the selected items from lv_Files to
lv_SelectedFile s.
I am currently using a loop on the selected indices to copy. This is quite a
slow process when there are a lot of entries selected in lv_Files.

There is also a Copy All button that first selects all indices, then loops
through lv_Files, individually copying to lv_SelectedFile s.

Is there a method to perform this copy without the loop? Some faster
implementation? I have not been able to find any documention or code
examples for such.
Nov 16 '05 #1
3 17311
Hi there... try this

object[] dest = new object[listBox1.Items. Count];
listBox1.Items. CopyTo(dest, 0);
listBox2.Items. AddRange(dest);

Regards,
--
Angel J. Hernández M.
MCSD

"CaffeineRu sh" <gr******@swbel l.net> escribió en el mensaje
news:3G******** *********@newss vr22.news.prodi gy.com...
I have two Listview controls on the stage:
lv_Files
lv_SelectedFile s

I have a function that copies the selected items from lv_Files to
lv_SelectedFile s.
I am currently using a loop on the selected indices to copy. This is quite a slow process when there are a lot of entries selected in lv_Files.

There is also a Copy All button that first selects all indices, then loops
through lv_Files, individually copying to lv_SelectedFile s.

Is there a method to perform this copy without the loop? Some faster
implementation? I have not been able to find any documention or code
examples for such.

Nov 16 '05 #2
I got the following to compile:

ListViewItem[] dest = new ListViewItem[lv_Files.Items. Count];
// object[] dest = new object[lv_Files.Items. Count];
lv_Files.Items. CopyTo(dest, 0);
lv_SelectedFile s.Items.AddRang e(dest);

but get the following 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.

Any ideas? Thanks!

"Angel J. Hernández" <an**********@h otmail.com> wrote in message news:u5******** ******@tk2msftn gp13.phx.gbl...
Hi there... try this

object[] dest = new object[listBox1.Items. Count];
listBox1.Items. CopyTo(dest, 0);
listBox2.Items. AddRange(dest);

Regards,


--
Angel J. Hernández M.
MCSD



"CaffeineRu sh" <gr******@swbel l.net> escribió en el mensaje
news:3G******** *********@newss vr22.news.prodi gy.com...
I have two Listview controls on the stage:
lv_Files
lv_SelectedFile s

I have a function that copies the selected items from lv_Files to
lv_SelectedFile s.
I am currently using a loop on the selected indices to copy. This is quite

a
slow process when there are a lot of entries selected in lv_Files.

There is also a Copy All button that first selects all indices, then loops
through lv_Files, individually copying to lv_SelectedFile s.

Is there a method to perform this copy without the loop? Some faster
implementation? I have not been able to find any documention or code
examples for such.


Nov 16 '05 #3
Hi,

I believe that "listBox2.Items .AddRange(...)" is key for
your performance goal.

And i think that loop (with "Clone()" of items) over your
"listBox1.Selec tedItems" should be solution.

Cheers!

Marcin
I got the following to compile:

ListViewItem[] dest = new ListViewItem[lv_Files.Items. Count];
// object[] dest = new object[lv_Files.Items. Count];
lv_Files.Items. CopyTo(dest, 0);
lv_SelectedFile s.Items.AddRang e(dest);

but get the following 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.

Any ideas? Thanks!

"Angel J. Hernández" <an**********@h otmail.com
<mailto:an***** *****@hotmail.c om>> wrote in message
news:u5******** ******@tk2msftn gp13.phx.gbl...
> Hi there... try this
>
> object[] dest = new object[listBox1.Items. Count];
> listBox1.Items. CopyTo(dest, 0);
> listBox2.Items. AddRange(dest);
>
> Regards,
>
>
> --
> Angel J. Hernández M.
> MCSD
>
>
>
> "CaffeineRu sh" <gr******@swbel l.net <mailto:gr***** *@swbell.net>>

escribió en el mensaje
> news:3G******** *********@newss vr22.news.prodi gy.com...
> > I have two Listview controls on the stage:
> > lv_Files
> > lv_SelectedFile s
> >
> > I have a function that copies the selected items from lv_Files to
> > lv_SelectedFile s.
> > I am currently using a loop on the selected indices to copy. This is quite
> a
> > slow process when there are a lot of entries selected in lv_Files.
> >
> > There is also a Copy All button that first selects all indices,

then loops > > through lv_Files, individually copying to lv_SelectedFile s.
> >
> > Is there a method to perform this copy without the loop? Some faster
> > implementation? I have not been able to find any documention or code
> > examples for such.
> >
> >

>
>

Nov 16 '05 #4

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

Similar topics

6
2616
by: Anushya | last post by:
Hi I am using Listview and inherited listview control overriding WndProc & PreProcessMessage in ListView. I need this to customize listview to display only the page the user scrolls to. Since i am populating listview with more than 200,000 items. It is too slow and tried virtual listview. But that doesnot allow me to add images in the...
2
4624
by: ltnats | last post by:
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...
1
8122
by: Mamatha | last post by:
Hi I have some items in listview. I want to copy the selected items from listview using the clip board mechanism in VB.NET. I used this code but it was not copied. For Each lsvrow As ListViewItem In ListView1.SelectedItems Clipboard.SetDataObject(lsvrow) Next
2
2485
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
1
3608
by: Dragan Ristic | last post by:
How to select all ListView items and then copy that to clipboard (VB 7)? Please help.
2
2253
by: a | last post by:
Hi, I inherit my class from listview. Is it possible to copy or extract information (ListViewItem) from the listview providing the index? Thanks
1
5414
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...
4
4490
by: Brian Gaze | last post by:
I have created a ListView control and have bound this to a datasource. Within the ItemTemplate of the ListView I have added another ListViewControl which is databound in the code behind. The idea is that when clicking on the "Show details" button the ListView for the appropriate row binds in the codebehind and displays the detail data for the...
1
1134
fmiboy
by: fmiboy | last post by:
Hi. File into the DateBase. Name in Listview, but file bytes in variable. I can't copy to listview which show Local Folder. Please help me......
0
7917
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. ...
1
7665
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...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5501
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...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
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...

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.