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

Raddocument selectall problem

4 Answers 81 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
François
Top achievements
Rank 1
François asked on 16 Feb 2011, 11:30 AM
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

4 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 21 Feb 2011, 10:57 AM
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
0
Vedran
Top achievements
Rank 1
answered on 10 May 2011, 11:34 AM
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
0
Iva Toteva
Telerik team
answered on 12 May 2011, 03:48 PM
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
0
Vedran
Top achievements
Rank 1
answered on 18 May 2011, 03:24 PM
Yes, that helped :)
Thanx a lot!
Tags
RichTextBox
Asked by
François
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Vedran
Top achievements
Rank 1
Share this question
or