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

How to Clear entire Richtextbox

4 Answers 645 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Maurizio
Top achievements
Rank 2
Maurizio asked on 29 Oct 2014, 10:01 AM
How do I clear the entire Content of a RadRichTextBox?

For some Reason I don't want to use:

MyRadRichTextBox.Document = new Telerik.Windows.Documents.Model.RadDocument();

4 Answers, 1 is accepted

Sort by
0
Maurizio
Top achievements
Rank 2
answered on 29 Oct 2014, 12:14 PM
I found it out myself:

MyRadRichTextBox.Document.Selection.SelectAll();
MyRadRichTextBox.Document.Delete(false);


Why is it so difficult to find such things in the Telerik documentation? MS Docu is much better...
0
Petya
Telerik team
answered on 03 Nov 2014, 09:08 AM
Hello Peter,

Thank you for your feedback, it is much appreciated. We will consider the suggestion in the future improvements of our documentation.

Please also note that while executing this code will clear the contents of the editor, the RadDocument instance preserves many other properties such as styles, document variables, history of the previously executed actions, properties of the first section, etc. That being said, you might not achieve exactly the desired result.

Let us know if any additional questions arise.

Regards,
Petya
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Steve
Top achievements
Rank 1
answered on 06 Jun 2019, 10:46 PM
Is there an answer to the question on how to clear the rich text box properly?
0
Tanya
Telerik team
answered on 11 Jun 2019, 10:41 AM
Hi Steve,

The proper approach is the one Maurizio posted on 29 Oct - to select all the content and then invoke the Delete() method. However, the method exposed by RadDocument is now obsolete and we recommend using the API of RadRichTextBox or RadDocumentEditor:
this.radRichTextBox.Document.Selection.SelectAll();
this.radRichTextBox.Delete(true);

Regards,
Tanya
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
RichTextBox
Asked by
Maurizio
Top achievements
Rank 2
Answers by
Maurizio
Top achievements
Rank 2
Petya
Telerik team
Steve
Top achievements
Rank 1
Tanya
Telerik team
Share this question
or