.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

SubDocument.Delete(DocumentRange) Method

Removes content from the specified range.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v21.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:

See Also