Hi, I am having some trouble displaying text in a list view control. I have several columns in my list view,
and I am not sure how to read each line from a text file and 'place' it in the column.
I know my code is a bit rough, but I am only a beginner. Thanks in advance!Code:Public Class Form1 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load OpenFileDialog_ResourceFile.InitialDirectory = ("C:\users\name\documents\studentProjects") End Sub Private Sub Update_Click(sender As System.Object, e As System.EventArgs) Handles btnSearch.Click lisvProjects.BeginUpdate() Dim reader As New System.IO.StreamReader(OpenFileDialog_ResourceFile.FileName) Dim lines As String = reader.ReadToEnd For Each line As String In lines lisvProjects.Items.Add(line) Next reader.Close() ' Keep reading a line until we hit the end of the file Do While Not reader.EndOfStream ' Read a line and add to lisvProjects lisvProjects.Items.Add(reader.ReadLine()) Loop reader.Close() End Sub Private Sub btnSelectFile_Click(sender As System.Object, e As System.EventArgs) Handles btnSelectFile.Click lisvProjects.Items.Clear() If OpenFileDialog_ResourceFile.ShowDialog() = DialogResult.OK Then txtProjectMainFile.Text = OpenFileDialog_ResourceFile.FileName Else Exit Sub End If End Sub End Class![]()




Reply With Quote