Copying from list view to clip board

ringworm

New member
Joined
Oct 20, 2009
Messages
4
Programming Experience
Beginner
Hi, How can I copy from a list view then paste it to excel? Many thanks
 
To be honest, it'd be alot easier to just recreate it in excel little by little. It would be pretty hard to actually copy the entire thing seeing as in list view youd have to do some retarded coding to be able to copy each row and column. I dont think its worth to go through all that trouble. just recreate it..
 
Here is an example that copies all selected items/rows in Listview to clipboard as a Tab delimited table:
VB.NET:
If Me.ListView1.SelectedItems.Count < 0 Then Exit Sub
Dim build As New System.Text.StringBuilder, row As New List(Of String)
For Each item As ListViewItem In Me.ListView1.SelectedItems
    For Each subitem As ListViewItem.ListViewSubItem In item.SubItems
        row.Add(subitem.Text)
    Next
    build.AppendLine(String.Join(vbTab, row.ToArray))
    row.Clear()
Next
Clipboard.SetText(build.ToString)
 
Back
Top