Import Text Document to Listview

Posts 1–4 of 4 · Page 1 of 1
Import Text Document to Listview
If anyone knows how to do this please paste the code below.
Do you want to display the contents of a specific .txt file, or do you want a list of all .txt files? Or?

Usually a listview is used to display columns of data. I'm not sure what you're trying to do. ?
Re:
To display 1 column of data.
Quote Originally Posted by linklance View Post
To display 1 column of data.
Code:
       
 For Each textLine As String In System. IO .File.ReadAllLines("C:/test.txt")
     ListView1.Items.Add(textLine)
 Next

'//remove the spaces From system. io . file -> mpgh converts certain words to ****'s  and won't display correctly.
Assuming the text file is small enough to read into ram in one go! If you have small ram and load a huge document, it may fail and crash.
Also, when updating a GUI control numerous times, to save CPU you can tell the control to "not redraw each time I add an item: only redraw once I'm finished adding items" - the difference can be large if you thousands of items to display. Todo:

Be sure to set ListView1's view property to "List" or it will display strangely.
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?