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

2 posts, 1 answers
  1. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 29 Nov 2011 Link to this post

    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:

    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.
  2. Answer
    Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 30 Nov 2011 Link to this post

    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.

    Iva Toteva
    the Telerik team

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

  3. DevCraft banner
Back to Top