How to copy text from RichTextBox?

I have a RichTextBox that contains index text and superscript, the problem is that I cannot copy the text as it is from RichTextBox, what I get is text without index or superscript as the source text.

I would be grateful if someone would tell me the right solution.

Here is my copy code:

TextRange copiedTextRange = new TextRange(richTextSourceText.Document.ContentStart, richTextSourceText.Document.ContentEnd);
MemoryStream memoryStream = new MemoryStream();
copiedTextRange .Save(memoryStream, DataFormats.Rtf);

Then here is my insert code:

TextRange pastedTextRange;
pastedTextRange= new TextRange(richTextDestinationText.Document.ContentStart, richTextDestinationText.Document.ContentEnd);
            pastedTextRange.Load(memoryStream, DataFormats.Rtf);
+3
source share

All Articles