Back to Devexpress

BookmarkCollection.Remove(Bookmark) Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-bookmarkcollection-dot-remove-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-bookmark-x29.md

latest4.6 KB
Original Source

BookmarkCollection.Remove(Bookmark) Method

Removes the specified bookmark from the collection.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
void Remove(
    Bookmark bookmark
)
vb
Sub Remove(
    bookmark As Bookmark
)

Parameters

NameTypeDescription
bookmarkBookmark

A Bookmark object specifying a bookmark in the document.

|

Example

The code sample below shows how to locate and remove bookmarks in the 6th paragraph:

csharp
using DevExpress.XtraRichEdit.API.Native;

using (var wordProcessor = new RichEditDocumentServer())
{
  wordProcessor.LoadDocument("Documents//Document.docx");
  Document document = wordProcessor.Document;

  var bookmarks =
     document.Bookmarks.Get(document.Paragraphs[5].Range);
  if (bookmarks != null)
  {
      foreach (Bookmark bookmark in bookmarks)
      {
        document.Bookmarks.Remove(bookmark);
      }
  }
}
vb
Imports DevExpress.XtraRichEdit.API.Native

Using wordProcessor As New RichEditDocumentServer()
  Dim document As Document = wordProcessor.Document
  Dim bookmarks = document.Bookmarks.Get(document.Paragraphs(5).Range)
  If bookmarks IsNot Nothing Then
    For Each bookmark As Bookmark In bookmarks
        document.Bookmarks.Remove(bookmark)
    Next bookmark
  End If
End Using

The following code snippets (auto-collected from DevExpress Examples) contain references to the Remove(Bookmark) 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.

winforms-richedit-iterate-through-all-sub-documents/CS/Form1.cs#L31

csharp
for (int i = subdoc.Bookmarks.Count - 1; i >= 0; i--)
        subdoc.Bookmarks.Remove(subdoc.Bookmarks[i]);
}));

word-document-api-iterate-through-all-sub-documents/CS/Program.cs#L45

csharp
for (int i = subdoc.Bookmarks.Count - 1; i >= 0; i--)
        subdoc.Bookmarks.Remove(subdoc.Bookmarks[i]);
}));

winforms-richedit-iterate-through-all-sub-documents/VB/Form1.vb#L22

vb
For i As Integer = subdoc.Bookmarks.Count - 1 To 0 Step -1
    subdoc.Bookmarks.Remove(subdoc.Bookmarks(i))
Next

word-document-api-iterate-through-all-sub-documents/VB/Program.vb#L40

vb
For i As Integer = subdoc.Bookmarks.Count - 1 To 0 Step -1
    subdoc.Bookmarks.Remove(subdoc.Bookmarks(i))
Next

See Also

Bookmarks

Create

Select(Bookmark)

BookmarkCollection Interface

BookmarkCollection Members

DevExpress.XtraRichEdit.API.Native Namespace