Copy multiple rows from one Listview to Another

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BeckyBair
    New Member
    • Dec 2007
    • 2

    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:
    Code:
    Private Sub cmdSetSeqNum_Click()
    
      Dim ItmX As ListItem
      
      On Error GoTo ERR_HNDL
      
      Set ItmX = lvwSampleMap.SelectedItem
      
      If (ItmX Is Nothing) Then Exit Sub
      
      ItmX.EnsureVisible
      
      ItmX = lvwInstrPositions.SelectedItem
      
      CheckChanges
      
      Exit Sub
      
    ERR_HNDL:
      StandardErrorOutput Err
      
    End Sub
    Any help/suggestions would be greatly appreciated and thanks in advance.

    ~Becky
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    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.)

    [CODE=vb]Private Sub Command1_Click( )
    Dim x As Object
    Dim i As Integer
    ' Ghost selected ListItem.
    If ListView1.Selec tedItem Is Nothing Then Exit Sub
    For i = 1 To ListView1.ListI tems.Count
    If ListView1.ListI tems(i).Selecte d = True Then
    ListView1.ListI tems(i).Ghosted = True
    End If
    Next i
    End Sub[/CODE]

    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.

    Comment

    Working...