How to Clear content in RichEditControl

By FoxLearn 8/30/2024 2:44:32 AM   165
If you're working with RichEditControl from DevExpress in a C# WinForms application, you can clear its content in a straightforward way.

How to clear content in RichEditControl

Depending on your specific needs, you might use other methods.

You can clear Text Using RichEditControl.Text Property as shown below.

richEditControl1.Text = string.Empty;

Clearing Content in RichEditControl (DevExpress)

To clear the content of a RichEditControl, You can invoke the RichEditControl.Document.Delete method as shown below.

// Assuming richEditControl1 is your RichEditControl
richEditControl1.Document.Delete(richEditControl1.Document.Range);

This approach results in clearing a current document content only.

If you want to clear the content of a RichEditControl while also removing all custom styles, you can use the CreateNewDocument method.

// Reset the document, clearing content and removing custom styles
richEditControl1.CreateNewDocument();