My code below is able to easily load textfile contents to a textBox, with Multiline.
FileInfo myFile = new FileInfo(@"D:\output.txt");
TextReader myData = myFile.OpenText();
textBox1.Text = myData.ReadToEnd();
myData.Close();
But when I try with ListBox, it fails to display anything. Why? How do I do the same with ListBox?
thanks.

4 answers
The ListBox uses an ObjectCollection of items rather than lines of text.
If the file contains line breaks for each item, I'd try:
answered one year ago by:
17279
494
thank you, it works perfectly.
is there a limit on the maximum number of rows that ListBox can display? I have data in the range of more than 20,000 rows, and it cannot display all of them. What is the limit then? thanks.
answered one year ago by:
494
I don't know what the limit is but I'd have thought that you don't really want to display more than 1000 items in the list box at once if you're expecting the user to have to scroll through them all.
I'd be inclined to implement a paging system with a Next and Prev button to navigate between pages and a label to display the current page.
answered one year ago by:
17279
thanks for your comment. It seems that Excel is more suitable for my huge dataset.
answered one year ago by:
494