RichTextBox removes escape character from the text

前端 未结 1 1817
刺人心
刺人心 2021-01-06 23:36

before adding the text to RTF property in RichTextBox, i make some processing on the text, add escape character then divide the data to multiline.

the text is

相关标签:
1条回答
  • 2021-01-07 00:31

    When your application targets .NET 4.6.2 (or below), RichTextBox instantiates RichEdit control version3 (versions are described here), when your application is retargeted to .NET 4.7.1, it instantiates Rich Edit version 4.1 (msftedit.dll). Difference in RTF representation is most likely caused by the newer version of the control. You can opt-out from using the newer version of Rich Edit even when your application targets 4.7 and above by adding app.config file with the following compatibility switch under AppContextSwitchOverrides tag:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
      </startup>
      <runtime>
        <AppContextSwitchOverrides
          value="Switch.System.Windows.Forms.DoNotLoadLatestRichEditControl=true" />
      </runtime>
    </configuration>
    

    Conversely you can load Rich Edit 4.1 in an application that targets .NET 4.6.2 by setting the above AppContextSwitch to false.

    0 讨论(0)
提交回复
热议问题