Text properties are not being saved

2 posts, 0 answers
  1. Wayne
    Wayne avatar
    17 posts
    Member since:
    Jan 2011

    Posted 15 Dec 2011 Link to this post


    When I set the text properties say to Bold in my RTB these are not saved to the DB. So when I re-load the RTB from the DB I get the text but not in Bold as I saved it.

    Below is the code how I save and re-load the data from and to my RTB.


    Fist my RTB.

    <rad:RadRichTextBox  Name="RTBReceiptFooter" IsReadOnly="False" DocumentContentChanged="TXTPropertyChanged_ReceiptFooter" DocumentInheritsDefaultStyleSettings="True" ShowFormattingSymbols="True" />

    Here I grab the text from the RTB in the xaml.cs:

    //Export Text

    private void TXTPropertyChanged_ReceiptFooter(object sender, EventArgs e)


        IDocumentFormatProvider exporter = new TxtFormatProvider();

                    using (MemoryStream stream = new MemoryStream())


                        exporter.Export(this.RTBReceiptFooter.Document, stream);

                        stream.Seek(0, SeekOrigin.Begin);

                        StreamReader reader = new StreamReader(stream);


                         _viewModel.MyText = reader.ReadToEnd();



    Here I get the text from the db in the xaml.cs:


    _LongDiscriptionSub = _viewModel.MyText;

    public void ProvideSubText()


        IDocumentFormatProvider provider = new TxtFormatProvider();

                using (var stream = new MemoryStream())


                    var writer = new StreamWriter(stream);



                    stream.Seek(0, SeekOrigin.Begin);

                    RTBReceiptFooter.Document = provider.Import(stream);


    Thanky very much

  2. Mike
    Mike avatar
    640 posts

    Posted 20 Dec 2011 Link to this post

    Hi Wayne,

    We noticed you are using TxtFormatProvider to persist RadRichTextBox document. TxtFormatProvider uses txt as underlying format thus it would not persist the rich-text content.

    You should use XamlFormatProvider, which on the other hand will persist all document structure (including rich-text formatting, headers/footer, comments, styles and so on) as a Xaml string.

    XamlFormatProvider also has APIs that would help you load and save the document directly to a string - to use them you should not cast the provider instance to IDocumentFormatProvider.

    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top