469,914 Members | 2,329 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,914 developers. It's quick & easy.

Copy multiple rows from one Listview to Another

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()
  3.   Dim ItmX As ListItem
  5.   On Error GoTo ERR_HNDL
  7.   Set ItmX = lvwSampleMap.SelectedItem
  9.   If (ItmX Is Nothing) Then Exit Sub
  11.   ItmX.EnsureVisible
  13.   ItmX = lvwInstrPositions.SelectedItem
  15.   CheckChanges
  17.   Exit Sub
  19. ERR_HNDL:
  20.   StandardErrorOutput Err
  22. End Sub
Any help/suggestions would be greatly appreciated and thanks in advance.

Dec 13 '07 #1
1 4658
8,435 Expert 8TB
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.

Similar topics

3 posts views Thread by simchajoy2000 | last post: by
7 posts views Thread by txplayboy2002 | last post: by
1 post views Thread by marfi95 | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.