UncleRonin
Well-known member
Yesterday I was working with a RichTextBox and decided to add some formatting to my logging (I've never formatted text in one before!! O_O) ...not quite what I expected!
Now, normally I work with plain unformatted text and I have an imposed limit on the number of characters I allow to be displayed in the GUI log. So I did my usual thing: After the length exceeds my cap I remove all the oldest lines from the log and set the most recent log info as the .Text property of the RTB... FAIL! All formatting was lost and things were ugly looking again. Sigh.
So eventually I worked around this and ended up using .AppendText to add any text to the RTB and using .Select(0, IndexOfTheFirstLineOfValidText) and then .SelectedText = String.Empty to remove any old text.
Is this the right way to do this or this there a better way out there (which I'm quite positive there must be!)?
Don't get me wrong, this works BUT it really doesn't feel so great...
Now, normally I work with plain unformatted text and I have an imposed limit on the number of characters I allow to be displayed in the GUI log. So I did my usual thing: After the length exceeds my cap I remove all the oldest lines from the log and set the most recent log info as the .Text property of the RTB... FAIL! All formatting was lost and things were ugly looking again. Sigh.
So eventually I worked around this and ended up using .AppendText to add any text to the RTB and using .Select(0, IndexOfTheFirstLineOfValidText) and then .SelectedText = String.Empty to remove any old text.
Is this the right way to do this or this there a better way out there (which I'm quite positive there must be!)?
Don't get me wrong, this works BUT it really doesn't feel so great...