I have a TextFile that contains Records. On Form Load I m saving those records into
the listview. I set the MultiSelect property of the listview to true.
I have one button, I want that suppose user Selects multiple items
in the listview by using ctrl. & Click on Button,Firts records are deleted from the ListView
& Then From The Textfile.
Mine Code is as Under.
Plz tell me how to delete records from the TextFile.
Mine TextFile Records-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim i As Integer Dim sFilename As String Dim sFileReader As System.IO.StreamReader Dim sarr() As String Dim sInputLine As String Dim lcount As Integer sFilename = "C:\Records.txt" If Dir(sFilename.ToString) <> "" Then sFileReader = System.IO.File.OpenText(sFilename) sInputLine = sFileReader.ReadLine() Do Until sInputLine Is Nothing sarr = Split(sInputLine, "^^") Call SaveToListView2(sarr(0), sarr(1)) sInputLine = sFileReader.ReadLine() Loop End If End Sub Private Sub SaveToListView2(ByVal roll As String, ByVal name As String) lvitem = ListView2.Items.Add(roll) lvitem.SubItems.Add(name) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim RowNum As ListViewItem For Each RowNum In ListView2.SelectedItems ListView2.Items.Remove(RowNum) Next End Sub
Button1_Click Code Deletes the Row well if we choose the row that has roll 2,3 ,4.
Suppose If I want to delete the Record 1^^Neha.
Then the Error is coming??
Plz tell me dat.
Second tell me how to delete that record from the TextFile Cz I have no idea how to do it??