This is a migrated thread and some comments may be shown as answers.

don't show the "enter" neither blank spaces

1 Answer 30 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Edward
Top achievements
Rank 1
Edward asked on 15 Oct 2010, 09:08 PM
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

1 Answer, 1 is accepted

Sort by
0
Ivailo Karamanolev
Telerik team
answered on 18 Oct 2010, 01:28 PM
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
Tags
RichTextBox
Asked by
Edward
Top achievements
Rank 1
Answers by
Ivailo Karamanolev
Telerik team
Share this question
or