How do I send varying text sized strings from one RichTextBox to another?

前端 未结 2 1909
温柔的废话
温柔的废话 2021-01-28 23:19

I have code that has chemical compounds that have small font for the subscript. I currently have this code that transfers it from one RichTextBox to another one on

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-28 23:44

    From the documentation on msdn:

    "The Text property does not return any information about the formatting applied to the contents of the RichTextBox. To get the rich text formatting (RTF) codes, use the Rtf property."

    So to assign the value, with formatting, use this:

    myRichTextBox.Rtf = otherRichTextBox.Rtf;
    

    I've replaced += with = because I'm not sure you meant to append the value, rather than just replace it. If you do use +=, you may run into issues due to the "rtf" codes being appended one after the other. However, give it a try... you may not run into any issues at all.

提交回复
热议问题