Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF RichTextBox and '\t'

I am having trouble with adding text to the RichTextBox with tabs in it. I have code similar to this:

var documentRange = new TextRange(this.Document.ContentStart, this.Document.ContentEnd);
documentRange.Text = "";
if(this.Code != null)
  this.AppendText(this.Code);

And when I do this I can see tabs in paragraphs that start with '\t' but if I actually delete the tab then press the Tab key, the indentation is wrong. In fact it's about half the size exactly. Also if I tab in the middle of a line the tabbing is different.

Also when I pull the Text out of the TextRange lines that start with tabs appear to not generate '\t's generated by pressing the Tab key. This is incredibly frustrating. Does anyone have advice or ideas how to work with this?

like image 990
justin.m.chase Avatar asked Jun 27 '26 04:06

justin.m.chase


1 Answers

The answer is that the Rich Text Box just has issues and is not good enough for advanced scenarios. Try a 3rd party or roll your own from scratch.

like image 164
justin.m.chase Avatar answered Jun 30 '26 19:06

justin.m.chase



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!