don't show the "enter" neither blank spaces

2 posts, 0 answers
  1. Edward
    Edward avatar
    1 posts
    Member since:
    Jul 2010

    Posted 15 Oct 2010 Link to this post

    Hello, how are you, could you helpe me please!!!!! :( i have a problem... when i save a file html since the control richtextbox, it's ok ... but when i open it don't show the blank spaces neither the "enter", all the words are in a only paragraph, and i can't show tables in the control with tags html.. i am using the code of example ...

    public RadDocument ImportHtml(string content)
            {
                IDocumentFormatProvider provider = new HtmlFormatProvider();
                RadDocument document;
                using (MemoryStream stream = new MemoryStream())
                {
                    StreamWriter writer = new StreamWriter(stream);
                    writer.Write(content);
                    writer.Flush();
                    stream.Seek(0, SeekOrigin.Begin);
                    document = provider.Import(stream);
                }

                return document;
            }

    And after ..
                        RadDocument rd = ImportXaml(reader.ReadToEnd());
                        rd.Selection.SelectAll();
                        richtextbox.SetText(" ");
                        richtextbox.SetText(rd.Selection.GetSelectedText());

    For example :
                         this is my document

    but the result is :
    For example: this is my document.

    :( i ll be hoping some soultion.... jeje sorry by my english

  2. Ivailo Karamanolev
    Admin
    Ivailo Karamanolev avatar
    276 posts

    Posted 18 Oct 2010 Link to this post

    Hi Edward,

    As you haven't mentioned the HTML you're trying to import, please make sure it's valid XHTML in order to achieve best results.
    As for the ImportHtml method, indeed it's correct as per the demo, however since the Q2 SP1 it can be shortened as:
    public RadDocument ImportHtml(string content) {
        return new HtmlFormatProvider().Import(content);
    }
    However, regarding the method you're using to import the document, I'd recommend you to avoid using the SetText as it loses all the formatting. Rather, use this code in order to put a document inside your RadRichTextBox:
    richtextbox.Document = ImportHtml(reader.ReadToEnd());
    Let us know if you need any further assistance.

    Regards,
    Ivailo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top