Skip to main content
.NET Framework 4.5.2+

SubDocument.Delete(DocumentRange) Method

Removes content from the specified range.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v22.1.Core.dll

Declaration

void Delete(
    DocumentRange range
)

Parameters

Name Type Description
range DocumentRange

A range with the content to delete.

Remarks

Use the Delete method to remove document content (text, images, etc.) located in the specified range.

The code sample below removes specific words from a document:

using DevExpress.XtraRichEdit.API.Native;

using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
{
    wordProcessor.LoadDocument("FirstLook.docx");
    RemoveSpecificWords(wordProcessor.Document);
}

static void RemoveSpecificWords(Document document)
{
    string word = "Ounce";
    DocumentRange[] found = document.FindAll
      (word, SearchOptions.WholeWord);
    foreach (DocumentRange range in found)
    {
        document.Delete(range);
    }
}

If the DocumentRange passed as the method parameter contains only table cells without the text surrounding the table, the Delete method clears the only the cells content. If you want do delete a table row or other table elements, utilize the following methods instead:

The following code snippets (auto-collected from DevExpress Examples) contain references to the Delete(DocumentRange) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also