+ " "
is doubly ineffective. First, strings are immutable
, so + does not change a string, it creates a brand new string and copies all old content plus a new one in this new string. Secondly, reading and then writing back the property
becomes dead slow when the text is long.
See more detailed explanation in my past answer: Difference Between Mutable , Immutable string in C#
Your picture disappears because you assign text and loose formatting. This properties treats the content of the control as the plain text
. You would need to operate the property
instead, but it would be slow by the reason I already explained.
Correct answer is asking the length of the content from the control itself, selecting the text at the very end with selection ends equal to zero. Then you need to assign the "selected text" property. You may also want to remember old cursor position and restore it after appending.
Look, you failed to tag your question with your UI library and did not specify exact type of
. You created a problem for me as writing the answer in the form of pseudo-code (see previous paragraph) is inconvenient. You also did not receive any code. Therefore, now try to write the code yourself. In don't want to write two version just because you did not ask the question properly. If you have any questions, I'll answer them.