Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

SubDocument.Delete(DocumentRange) Method

Removes content from the specified range.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v24.2.Core.dll

NuGet Package: DevExpress.RichEdit.Core

#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);
    }
}

#Delete Table Cell Content

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:

#Delete Nested Fields

To delete a nested field, set the parent field’s ShowCodes property to true. Use the Field.Parent property to access the parent field.

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