473,503 Members | 1,804 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_SelectedFiles

I have a function that copies the selected items from lv_Files to
lv_SelectedFiles.
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_SelectedFiles.

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 17301
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

"CaffeineRush" <gr******@swbell.net> escribió en el mensaje
news:3G*****************@newssvr22.news.prodigy.co m...
I have two Listview controls on the stage:
lv_Files
lv_SelectedFiles

I have a function that copies the selected items from lv_Files to
lv_SelectedFiles.
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_SelectedFiles.

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_SelectedFiles.Items.AddRange(dest);

but get the following System.ArgumentException 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**********@hotmail.com> wrote in message news:u5**************@tk2msftngp13.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



"CaffeineRush" <gr******@swbell.net> escribió en el mensaje
news:3G*****************@newssvr22.news.prodigy.co m...
I have two Listview controls on the stage:
lv_Files
lv_SelectedFiles

I have a function that copies the selected items from lv_Files to
lv_SelectedFiles.
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_SelectedFiles.

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.SelectedItems" 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_SelectedFiles.Items.AddRange(dest);

but get the following System.ArgumentException 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**********@hotmail.com
<mailto:an**********@hotmail.com>> wrote in message
news:u5**************@tk2msftngp13.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
>
>
>
> "CaffeineRush" <gr******@swbell.net <mailto:gr******@swbell.net>>

escribió en el mensaje
> news:3G*****************@newssvr22.news.prodigy.co m...
> > I have two Listview controls on the stage:
> > lv_Files
> > lv_SelectedFiles
> >
> > I have a function that copies the selected items from lv_Files to
> > lv_SelectedFiles.
> > 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_SelectedFiles.
> >
> > 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
2605
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...
2
4616
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...
1
8100
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...
2
2481
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...
1
3603
by: Dragan Ristic | last post by:
How to select all ListView items and then copy that to clipboard (VB 7)? Please help.
2
2246
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
5390
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...
4
4480
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...
1
1127
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
7199
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,...
0
7273
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,...
0
7322
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...
1
6982
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...
1
5000
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...
0
4667
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...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
374
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...

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.