Also what is the easiest way to insert text into a RadDocument in code (to put a timestamp at the footer or something like that) ?
Thank you,
Doug
3 Answers, 1 is accepted
You can have only one document in RadRichTextBox. If you have several files, you can import them into separate documents and then "merge" them into one as described in the the last post in this forum thread.
If you would like to insert a smaller piece of text at a random position in a document, you can use the rich text box's Insert method, which inserts text at the current caret position with the style of the span at the place in the document where you insert the text. If you like, you can also use the InsertInline method and pass a new Span as a parameter. You can set the span's Text and customize its style.
You can also manipulate the caret position before invoking the insert methods in order to change the position where you wish the text to appear. You can find more information on document positions and their usage here.
If you need further assistance, do not hesitate to get back to us.
Iva
the Telerik team
Im loading a richtextbox with a docx using this code:
DocxFormatProvider docxProvider = new DocxFormatProvider();
RadDocument document = docxProvider.Import(Resources.RichTextBox_for_WinForms);
this.radRichTextBox1.Document = document;
I would like to know if i can append more than one file like this to the same richtextbox, is that possible?
You can use the DocumentFragment class to merge multiple documents and set the result to an instance of RadRichTextBox:
private
void
Button_Click(
object
sender, RoutedEventArgs e)
{
// you can use other format providers as well
TxtFormatProvider provider =
new
TxtFormatProvider();
List<RadDocument> documents =
new
List<RadDocument>()
{
// this will create some test documents that will be merged
provider.Import(
"text 1"
),
provider.Import(
"text 2"
),
provider.Import(
"text 3"
),
};
RadDocument mergedDocument =
new
RadDocument();
foreach
(var document
in
documents)
{
mergedDocument.CaretPosition.MoveToLastPositionInDocument();
mergedDocument.InsertFragment(
new
DocumentFragment(document));
}
// set the document to RadRichTextBox
this
.radRichTextBox.Document = mergedDocument;
}
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 >>