By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,593 Members | 2,006 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,593 IT Pros & Developers. It's quick & easy.

Copy multiple rows from one Listview to Another

P: 2
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:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSetSeqNum_Click()
  2.  
  3.   Dim ItmX As ListItem
  4.  
  5.   On Error GoTo ERR_HNDL
  6.  
  7.   Set ItmX = lvwSampleMap.SelectedItem
  8.  
  9.   If (ItmX Is Nothing) Then Exit Sub
  10.  
  11.   ItmX.EnsureVisible
  12.  
  13.   ItmX = lvwInstrPositions.SelectedItem
  14.  
  15.   CheckChanges
  16.  
  17.   Exit Sub
  18.  
  19. ERR_HNDL:
  20.   StandardErrorOutput Err
  21.  
  22. End Sub
  23.  
Any help/suggestions would be greatly appreciated and thanks in advance.

~Becky
Dec 13 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 5K+
P: 8,434
From the VB6 doco, here's an example which shows how to pick multiple selected items from a ListView. (The example sets their Ghosted property, but you can ignore that.)

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.    Dim x As Object
  3.    Dim i As Integer
  4.    ' Ghost selected ListItem.
  5. If ListView1.SelectedItem Is Nothing Then Exit Sub
  6.    For i = 1 To ListView1.ListItems.Count
  7.       If ListView1.ListItems(i).Selected = True Then
  8.          ListView1.ListItems(i).Ghosted = True
  9.       End If
  10.    Next i
  11. End Sub
I'd suggest you might want to create a collection. When you do this loop to pick out the selected items, add them to the collection. Then you can pull them from the collection to put in the other control.
Dec 14 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.