ok. i kinda got this going, but i have multi columns that i want to save. i'm missing something here...just dont know what.
I can get one column to save only. but i have columns like "name", "address", "phone number"
here is my Form1 code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListView1.Columns.Add("Name", 100, HorizontalAlignment.Left)
ListView1.Columns.Add("Phone", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Address", 100, HorizontalAlignment.Right)
End Sub
Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
End Sub
Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
lstAdd.removeFromList()
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
lstAdd.save()
End Sub
End Class
this is part of the listboxInst class for save
Public Sub save()
Form1.SaveFileDialog1.ShowDialog()
Dim path As String
Dim allItems As String
Dim i As Integer
Try
path = Form1.SaveFileDialog1.FileName
allItems = ""
For i = 0 To lv.ListView.Items.Count - 1
allItems = allItems & lv.ListView.Items.Item(i).Text & lv.SubItems.Item(i).Text & vbNewLine
Next
allItems = allItems.Trim
Catch ex As Exception
End Try
Try
If My.Computer.FileSystem.FileExists(path) Then
My.Computer.FileSystem.DeleteFile(path)
End If
My.Computer.FileSystem.WriteAllText(path, allItems, False)
Catch ex As Exception
MsgBox("Error" & vbNewLine & ex.Message, MsgBoxStyle.Exclamation, "error")
End Try
End Sub
if anyone can help i'd be very appreciative.
I can get one column to save only. but i have columns like "name", "address", "phone number"
here is my Form1 code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListView1.Columns.Add("Name", 100, HorizontalAlignment.Left)
ListView1.Columns.Add("Phone", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Address", 100, HorizontalAlignment.Right)
End Sub
Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
End Sub
Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
lstAdd.removeFromList()
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
lstAdd.save()
End Sub
End Class
this is part of the listboxInst class for save
Public Sub save()
Form1.SaveFileDialog1.ShowDialog()
Dim path As String
Dim allItems As String
Dim i As Integer
Try
path = Form1.SaveFileDialog1.FileName
allItems = ""
For i = 0 To lv.ListView.Items.Count - 1
allItems = allItems & lv.ListView.Items.Item(i).Text & lv.SubItems.Item(i).Text & vbNewLine
Next
allItems = allItems.Trim
Catch ex As Exception
End Try
Try
If My.Computer.FileSystem.FileExists(path) Then
My.Computer.FileSystem.DeleteFile(path)
End If
My.Computer.FileSystem.WriteAllText(path, allItems, False)
Catch ex As Exception
MsgBox("Error" & vbNewLine & ex.Message, MsgBoxStyle.Exclamation, "error")
End Try
End Sub
if anyone can help i'd be very appreciative.