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

Appen Text at the end of a document

1 Answer 66 Views
RichTextBox (obsolete as of Q3 2014 SP1)
This is a migrated thread and some comments may be shown as answers.
francesco
Top achievements
Rank 2
francesco asked on 25 Feb 2012, 02:24 PM
Does anyone trying to append programmatically some text at the end of an existing RadDocument?

This part of code doesen't works well:

Telerik.WinControls.RichTextBox.FormatProviders.IDocumentFormatProvider p = new Telerik.WinControls.RichTextBox.FileFormats.Html.HtmlFormatProvider();
Telerik.WinControls.RichTextBox.Model.RadDocument document = p.Import(System.Text.Encoding.UTF8.GetBytes(pBody));
document.CaretPosition.MoveToLastPositionInDocument();
document.InsertLineBreak();
document.Insert(pNote, style);
 
The text was appended at the end of the first word of the document.
Anyone could help me?

Thanks
  Francesco

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 28 Feb 2012, 10:53 AM
Hi Francesco,

Thank you for writing.

In your code you are instantiating a provider (named document) and trying to insert a text in it. The correct approach is to have the import the context via the provider to a document and then use the document to add your text. Attached you can find a sample application demonstrating this approach. 

I hope that you find this information useful. Let me know if I can be of further assistance. 
 
Kind regards,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
RichTextBox (obsolete as of Q3 2014 SP1)
Asked by
francesco
Top achievements
Rank 2
Answers by
Stefan
Telerik team
Share this question
or