T
Todd Brown
I'm trying to programatically add new lines to the content of a
(System.Windows.Forms.)TextBox and, while I have found a solution, I
feel that it can't be very efficient. There must be a better way.
I first tried:
textBox.AppendText( "\n New line" );
But that didn't work. Nor did variations on the theme, like
textBox.Text += ....
Here's what *did* work:
String[] lines = new String[textBox.Lines.Length+1];
textBox.Lines.CopyTo( lines, 0 );
lines[lines.Length-1] = textBox.Text;
textBox.Lines = lines;
This seems very inefficient since we're copying the *entire* contents of
the text box just to add a single new line.
Am I missing something here?
-- T
(System.Windows.Forms.)TextBox and, while I have found a solution, I
feel that it can't be very efficient. There must be a better way.
I first tried:
textBox.AppendText( "\n New line" );
But that didn't work. Nor did variations on the theme, like
textBox.Text += ....
Here's what *did* work:
String[] lines = new String[textBox.Lines.Length+1];
textBox.Lines.CopyTo( lines, 0 );
lines[lines.Length-1] = textBox.Text;
textBox.Lines = lines;
This seems very inefficient since we're copying the *entire* contents of
the text box just to add a single new line.
Am I missing something here?
-- T