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

Document.Insert (myText, null) null style giving error now

1 Answer 28 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
danparker276
Top achievements
Rank 2
danparker276 asked on 29 Nov 2011, 07:52 PM
I updated my Silverlight libraries and my code where I would insert at points into a rich text box would throw an error now.  I haven't updated in a 3-6 months (internal builds).  I fixed it by just doing a Insert with out the document and it works.
Old code:
this.myRichTextBox.Document.Insert(myText, null);

New code:
this.myRichTextBox.Insert(myText);

It seems to work ok like this and inserts in the right place.  Anything wrong with what I'm doing?

I don't really care about styles.  I really only use the rich text box because I like it's spell checker with the red line under the word.  I just use it as a regular text input box.

1 Answer, 1 is accepted

Sort by
0
Accepted
Iva Toteva
Telerik team
answered on 30 Nov 2011, 07:39 PM
Hello Dan,

In the latest Q3 release - 2011.3.1116 we introduced a new functionality - styles. Before, the StyleDefinition objects were only used to set local values of the properties such as FontSize, FontWeight, etc. With the new implementation, setting a style with value null will be a problem.

Overall, you have two solutions:
1. Create a StyleDefinition, set some of its properties and pass it as an argument.
2. Use the method or RadRichTextBox.

There are code-snippets with both approaches and a description of the difference in this article. The main difference is that the undo/redo stack will be cleared if you use the Insert method of RadDocument as you have been doing by now.

Regards,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
RichTextBox
Asked by
danparker276
Top achievements
Rank 2
Answers by
Iva Toteva
Telerik team
Share this question
or