RichTextBox formatting losing format when I append text

  • Thread starter Thread starter JezB
  • Start date Start date
J

JezB

I have a RichTextBox that I am formatting with colours/fonts etc. But
whenever I append some text on the end it's losing all formatting, eg:-

output.Text += "some extra text";

This reverts the existing text to the base colours/font even though I have
previously applied and seen the correct formatting.

How can I append text without losing all my formatting?
 
I just found out myself, do this instead :-

output.SelectionStart = output.Text.Length;

output.SelectedText = "some extra text";
 
That's the problem with starting out and trying to learn .NET - it's so huge
that as soon as you find a way to do something you don't consider whether
it's the best way to do it, you're just happy that it works and get into the
habit of doing it !

Yes, your solution works :)
 
Back
Top