Copy and paste a section of a listview control to another application

Started by Petrus Vorster, February 13, 2015, 08:28:09 AM

Previous topic - Next topic

Petrus Vorster

hi all

I prefer my Listview to be fullrowselect, but now I need to be able to select more than one row, copy it and paste it in that "sectioned" format into an e-mail for example. (In other words retain the tabular look when pasting)

The more than one row selection is easy, but how can you make it copy and paste into another app?
There might have been posts here that i have missed.

-Regards
Peter

David Kenny

This might get you started on the correct path:

    Local Table As String
    Local i,j   As Integer
   
    For i = StrartRow To EndRow             'This is just an example, you would need to set the values as you need
        For j = 0 To ColumnCt -1            'This assumes you want all columns (you need to set the ColumnCt also)
            Table += FF_ListView_GetItemText( MainForm_ListView1, i,j) + $Tab
       
        Next j
        Table = Left$(Table,-1) + $CrLf     'Take off the last Tab before adding the $CrLf
    Next i
    Table = Left$(Table,-1)                   'Take off the last Carrage-return Linefeed                                             
    FF_ClipboardSetText Table               'Copy the Table to the Clipboard
   


This will copy the selected items into the Clipboard, ready for you to paste into another program.  I made some assumptions when making this snippet, let me know if you need more info or explanation.

Petrus Vorster

-Regards
Peter

David Kenny

You are welcome Peter.

Were you able to get that working for you?

Petrus Vorster

Hi David.

Been away for work & on the road until Sunday. It makes perfect sense if you read it.
It has to work!
Cant wait to get busy with this!
-Regards
Peter