I have a problem when I try to display the list into the textbox. It only displays the last line from the list.txt file. I think for each new line it overwrites the first line from the textbox all the time ? thus showing only the last line from the file ?
what is it I need to think of to get it right ?
private void Form1_Load(object sender, EventArgs e)
{
const string f = "list.txt";
List<string> myList = new List<string>();
using (StreamReader r = new StreamReader(f))
{
string line;
while ((line = r.ReadLine()) != null)
{
myList.Add(line);
}
}
foreach (string s in myList)
{
textBox1.Text = string.Join(Environment.NewLine, s);
}
}
Instead of this:
Try:
And also make sure multiline property of textbox1 is set to true.