Ticket T329047
Visible to All Users

How to save/load RTF text as stream in database and bind to RichEditControl in WPF

created 9 years ago

Hello!

I have created an application using the Scaffolding  Wizard and now want to replace the DataLayoutItem controls through a RichEditControl.
In the data model I have in the Properties with [DataType (DataType.MultilineText)].

I like to save a RTF text as a stream in the database and load the content to the RichEditControl.

Could you please prepare me an example for me.

Thank you very, very much advance and best regards!

Fritz

Answers approved by DevExpress Support

created 9 years ago (modified 9 years ago)

Hello Fritz,
You can use the corresponding overloads of the RichEditControl.LoadDocument and RichEditControl.SaveDocument methods to load or save a document to a stream. Also, these overloads provide a DocumentFormat parameter. Use the DocumentFormat.Rtf parameter value in the methods to save and load a document in the RTF format. Please refer to the following code snippet:

C#
richEditControl1.LoadDocument(stream1, DocumentFormat.Rtf); //... richEditControl1.SaveDocument(stream2, DocumentFormat.Rtf);

If you want to bind the RichEditControl's Content to the view model property storing RTF text, I recommend you use the approach described in the How to bind RichEditControl to a text in different formats example. When the view model property is changed, you will be able to pass these changes to the database.
I hope that you find this information helpful.

    Show previous comments (2)
    FR FR
    Friedrich Rudolf 9 years ago

      Hello Oleg!
      Thank you very much for your support, it works perfect!
      Nice greetings!
      Fritz

      DevExpress Support Team 9 years ago

        You are welcome, Friedrich!
        I am happy to hear that my assistance was helpful to you.
        Should you have additional questions regarding our products or need my further assistance, do not hesitate to contact me.

        M M
        Mike Walker in Chicago 5 years ago

          Still useful! Thanks Oleg!

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.