dr223
June 17th, 2009, 06:04 AM
Hallo,
Please could anyone tell me the code I can incorporate in my application which will allow me to transfer data from my listview to a notepad or .txt file.
Any suitable website which such information will be very helpful indeed.
Thanks
HanneSThEGreaT
June 17th, 2009, 09:48 AM
This will work Line by Line ( Row by Row )
Add a button, and add the following :
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Using LVStream As New IO.StreamWriter("LVEx.txt")
For Each LVi As ListViewItem In lvExample.Items
Dim LVRow As String = ""
For Each LVCell As ListViewItem.ListViewSubItem In LVi.SubItems
LVRow &= LVCell.Text & ","
Next
LVRow = LVRow.Remove(LVRow.Length - 1, 1)
LVStream.WriteLine(LVRow)
Next
End Using
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lvExample.Items.Add("Test0") ' test data
lvExample.Items(0).SubItems.Add("Test1")' test data
lvExample.Items(0).SubItems.Add("Test2")' test data
End Sub