4 Answers, 1 is accepted
0
Accepted
Hello Simon,
Another option (if you wish to be able to undo the operation) would be to select everything and delete it like this:
If you have other questions, do not hesitate to contact us again. Greetings,
Iva
the Telerik team
The easiest way would be to create a new document and assign it to the Document property of the rich text box:
this
.radRichTextBox.Document =
new
RadDocument();
Another option (if you wish to be able to undo the operation) would be to select everything and delete it like this:
this
.radRichTextBox.Document.Selection.SelectAll();
this
.radRichTextBox.Document.Delete(
false
);
If you have other questions, do not hesitate to contact us again. Greetings,
Iva
the Telerik team
0
Simon
Top achievements
Rank 1
answered on 31 Mar 2011, 07:17 PM
Thanks you Iva,
I prefere option #2 as it will keep all your documents properties values.
I prefere option #2 as it will keep all your documents properties values.
0
Keith
Top achievements
Rank 1
answered on 15 Jun 2011, 06:46 PM
I have found for the second option that you should test to see if the Selection IsEmpty before trying to Delete it or you will get a stack overflow error:
someRichTextBox.Document.Selection.SelectAll();
if
( !someRichTextBox.Document.Selection.IsEmpty )
{
someRichTextBox.Document.Delete(
false
);
}
0
Hello Keith,
We have revised this behavior and starting from the next release - the Q2 Beta, the document will be measured and arranged for you when you invoke an operation that requires that the document is measured.
If that does not help, we would appreciate a sample demo illustrating the behavior you are observing. Kind regards,
Iva
the Telerik team
StackOverflowException can only occur if you are trying to delete the content of the document when it has not been measured and arranged. The document is automatically measured and arranged by Silverlight when it is shown in the editor, but if you want to perform the modification before that, you have to manually measure and arrange it in the following way:
this
.radRichTextBox.Document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
this
.radRichTextBox.Document.Arrange(
new
RectangleF(PointF.Empty,
this
.radRichTextBox.Document.DesiredSize));
We have revised this behavior and starting from the next release - the Q2 Beta, the document will be measured and arranged for you when you invoke an operation that requires that the document is measured.
If that does not help, we would appreciate a sample demo illustrating the behavior you are observing. Kind regards,
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