c# How to read and write from multiline textBox line by line?
The property Lines is there for you
if(textBox1.Lines.Length > 0)
textBox2.Text=textBox1.Lines[0];
or, put your textboxes ordered in a temporary array and loop on them (of course we should always check the number of lines present in textBox1)
TextBox[] text = new TextBox[] {textBox2, textBox3, textBox4};
if(textBox.Lines.Length >= 3)
{
for(int x = 0; x < 3; x++)
text[x] = textBox1.Lines[x];
}
Simple programming read and write a one-by-one line from multiline textBox in C#
Write line one-by-one:
textbox1.AppendText("11111111+");
textbox1.AppendText("\r\n222222222");
textbox1.AppendText("\r\n333333333");
textbox1.AppendText("\r\n444444444");
textbox1.AppendText("\r\n555555555");
Read line one-by-one:
for (int i = 0; i < textbox1.Lines.Length; i++)
{
textbox2.Text += textbox1.Lines[i] + "\r\n";
}