You can do this with a single line of code:
1 set the Multiline, AcceptsTab, and AcceptsReturn properties of textBox1 to 'true.
2 set the Multiline, AcceptsTab, and AcceptsReturn properties of textBox2 to 'false.
note: these are the default values.
3 in a Button 'Click EventHandler:
textBox2.Text = textBox1.Text;
Now, do not be surprised if, when there is no white space at the end of each line in textBox1, what you get in textBox2 is lines-run-together. I'd guess you don't really want to lose all indication of where lines ended ... so:
private Char myLineDelimiter = '|';
private bool doTrimLines = true;
private void MoveTextButton_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
foreach (string line in textBox1.Lines)
{
sb.Append(doTrimLines ? line.Trim() : line);
sb.Append(myLineDelimiter);
}
textBox2.Text = sb.ToString();
}
Using a 'StringBuilder avoids excess memory consumption that may come into play with manipulating large collections of strings: it's used here out of habit, more than necessity.
Note: do you really want to trim the whitespace in each line ? If you do not trim the lines, and the lines have white-space made of Tabs, those Tabs will appear in textBox2 even though you set its AcceptsTab property to 'false: that's a bug in the TextBox.