Hi,
Im trying to use RadRichTextBox together with the Ribbon control to get a Word-like text editor in my application.
So far I've initialized the editor with some content, which can be either plain text, RTF of HTML, so I used the different format providers and its working like a charm.
Now I want to be able to insert content at the caret position. For inserting plain text, I'm using the Insert method, and its working fine, but how do I insert RTF and HTML? On top of that, the inserted RTF or HTML should keep its original formatting and style.
/giereck
Im trying to use RadRichTextBox together with the Ribbon control to get a Word-like text editor in my application.
So far I've initialized the editor with some content, which can be either plain text, RTF of HTML, so I used the different format providers and its working like a charm.
Now I want to be able to insert content at the caret position. For inserting plain text, I'm using the Insert method, and its working fine, but how do I insert RTF and HTML? On top of that, the inserted RTF or HTML should keep its original formatting and style.
/giereck
5 Answers, 1 is accepted
0
Hi Giereck,
You can use RadRichTextBox.InsertFragment method. DocumentFragment itself could be created from an instance of RadDocument, created from RtfFormatProvider or HtmlFormatProvider, depending on the format you want to import.
Boby
the Telerik team
You can use RadRichTextBox.InsertFragment method. DocumentFragment itself could be created from an instance of RadDocument, created from RtfFormatProvider or HtmlFormatProvider, depending on the format you want to import.
Don't hesitate to contact us if you have other questions.
Regards,Boby
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0

Giereck
Top achievements
Rank 1
answered on 22 Nov 2011, 11:57 AM
Hi Boby,
Thank you for your reply!
How do I create a DocumentFragment from a RadDocument?
/Giereck
Thank you for your reply!
How do I create a DocumentFragment from a RadDocument?
/Giereck
0
Hi Giereck,
Before that, a document fragment could only be created through selection:
Greetings,
Iva Toteva
the Telerik team
In the versions starting from Q2 SP1 (2011.2.920), you can create a DocumentFragment like this:
DocumentFragment fragment =
new
DocumentFragment(document);
this
.editor.InsertFragment(fragment);
//Insert the fragment at caret position
document.Selection.SelectAll();
DocumentFragment fragment = document.Selection.CopySelectedDocumentElements();
Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0

Michael Hilgers
Top achievements
Rank 1
answered on 05 Dec 2012, 12:07 PM
Hello Everyone,
is this no longer valid?
For me with Q3 2012 it says that there is no constructor taking 1 argument. But there aren't any constructores!
How can i create a DocumentFragment now??
Best Regards,
Michael
P.S.: I'm on WinForms, not on WPF, but it this a difference?
is this no longer valid?
DocumentFragment fragment =
new
DocumentFragment(document);
For me with Q3 2012 it says that there is no constructor taking 1 argument. But there aren't any constructores!
How can i create a DocumentFragment now??
Best Regards,
Michael
P.S.: I'm on WinForms, not on WPF, but it this a difference?
0
Hi Michael,
Thank you for writing.
Yes there is a difference, so please address your question in the WinForms forums: http://www.telerik.com/community/forums/winforms/richtextbox.aspx, where our colleagues will assist you.
Kind regards,
Stefan
the Telerik team
Thank you for writing.
Yes there is a difference, so please address your question in the WinForms forums: http://www.telerik.com/community/forums/winforms/richtextbox.aspx, where our colleagues will assist you.
Kind regards,
Stefan
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.