Raddocument selectall problem

5 posts, 0 answers
  1. François
    François avatar
    1 posts
    Member since:
    Oct 2010

    Posted 16 Feb 2011 Link to this post

    Hi,

    I have a problem whith the instruction selection.selectall() in a raddocument.
    The last character is not be changed where I use the

    UpdateSelectedSpansStyle to change forecolor and size of the text.


    i use version 2010.3.1314 (jan 14, 2011) of radcontrols for silverlight

    Thank you very much.

    François

  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 21 Feb 2011 Link to this post

    Hi François,

    The last character in the document must be the paragraph-end symbol of the last paragraph and by design, it cannot be selected and its style cannot be changed.
    If the last character in your document is not that symbol, the document's structure is invalid. This can happen if you manipulate programmatically the document structure after the document has been measured and arranged (which happens automatically when you show the RadRichTextBox on the screen). 
    If you want to change the font family and font size of the whole document, you can use RadRichTextBox's properties like this:

    public void SetDefaultFontPropertiesToEditor(RadRichTextBox editor)
    {
        editor.FontFamily = new FontFamily("Comic Sans MS");
        editor.FontSize = Unit.PointToDip(12);
        editor.FontStyle = FontStyles.Italic;
        editor.FontWeight = FontWeights.Bold;
        editor.DocumentInheritsDefaultStyleSettings = true;
    }

    Setting them in XAML also works.
    Let us know if you need further assistance.

    Greetings,
    Iva
    the Telerik team
  3. Vedran
    Vedran avatar
    6 posts
    Member since:
    Mar 2011

    Posted 10 May 2011 Link to this post

    Hi,
    I have a problem with RadDocument.SelectAll() method - it does not select last element in document; as you said, last paragraph is not closed (DocumentFragment.IsLastParagraphClosed is false).
    I just import RadDocument from byte array, but do nothinig with document structure.
    How can I add paragraph-end symbol?
    or
    How can I copy whole document?
    (I need to paste content of one document into another document)

    Thanx, Vedran
  4. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 12 May 2011 Link to this post

    Hi Vedran,

    François's issue was different than the one you are encountering. You can test how in the demo if ShowFormattingSymbols is enabled, select all does not select the last paragraph-end symbol. This behavior is by design, but it does not affect copying or changing the formatting of the whole document.

    In your case, the problem is that the document is not measured and arranged before you try to select and copy it. Please refer to this forum thread for the answer to your question. You need the following code in particular:
    document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
    document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize));

     
    Best wishes,
    Iva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Vedran
    Vedran avatar
    6 posts
    Member since:
    Mar 2011

    Posted 18 May 2011 Link to this post

    Yes, that helped :)
    Thanx a lot!
Back to Top