[Help]Saving ListView[Solved]

Posts 16–20 of 20 · Page 2 of 2


PS: Your code is just working like that:

Code:
Private Sub SaveListview()
        Dim full As String = ""

        For i = 0 To ListView1.Items.Count - 1
            full = ListView1.Items(i).SubItems(0).Text & Delimiter & ListView1.Items(i).SubItems(1).Text & Delimiter & ListView1.Items(i).SubItems(2).Text & Delimiter & ListView1.Items(i).SubItems(3).Text & vbNewLine
        Next

        Using sWrite As New IO.StreamWriter(File)
            sWrite.Write(full, True)
        End Using
    End Sub

    Private Sub GetContent()
        If IO.File.Exists(File) Then
            Using sRead As New IO.StreamReader(File)
                While Not sRead.EndOfStream
                    Dim splitted() As String = Split(sRead.ReadLine, Delimiter)
                    ListView1.Items.Add(splitted(0))
                    ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(splitted(1))
                    ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(splitted(2))
                    ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(splitted(3))
                End While
            End Using
        End If
    End Sub
Looks good

@Jason, mark this as solved.
Marked solved, you guys know the deal. However Kevin's code could be a little cleaner
Posts 16–20 of 20 · Page 2 of 2
This thread is closed for replies.

Tags for this Thread

None

Talk with us