# Manipulating Annotations

This article outlines the most commonly used manipulations with regard to **Annotations**.

The types of manipulations that can be performed on annotations include:

* Presentation in the document;

* Retrieving annotations;

* Inserting an annotation;

* Deleting an annotation;

* Splitting an annotation at a given position.

## Presentation

By default, all annotations are markup-only in the sense that they do not have any appearance. If you want to display a highlight, range brackets or anything else, you can use the UI layers feature of **RadRichTextEditor**. You can read more about them in [this article](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/how-to/customize-presentation-through-ui-layers).

## Methods for Retrieving Annotations

* **RadDocument** exposes the following general methods for retrieving annotation markers or checking if such exist in the document at all:

```C#
bool containsBookamrks = this.radRichTextEditor1.Document.ContainsAnnotationMarkersOfType<BookmarkRangeStart>();

IEnumerable<BookmarkRangeStart> markers = this.radRichTextEditor1.Document.GetAnnotationMarkersOfType<BookmarkRangeStart>();

```

```VB.NET
Dim containsBookamrks As Boolean = Me.radRichTextEditor1.Document.ContainsAnnotationMarkersOfType(Of BookmarkRangeStart)()

Dim markers As IEnumerable(Of BookmarkRangeStart) = Me.radRichTextEditor1.Document.GetAnnotationMarkersOfType(Of BookmarkRangeStart)()

```

* Methods for retrieving the containing annotations around a particular inline. This is particularly convenient if you would like to perform checks against the position where the caret is at. First, you can obtain the current inline like this:

```C#
Inline currentInline = this.radRichTextEditor1.Document.CaretPosition.GetCurrentInline();

```

```VB.NET
Dim currentInline As Inline = Me.radRichTextEditor1.Document.CaretPosition.GetCurrentInline()

```

and then, check if this inline is contained in a range using one of the methods below:

```C#
bool isInRange = this.radRichTextEditor1.Document.IsInAnnotationRange<BookmarkRangeStart>(inline);

IEnumerable<BookmarkRangeStart> ranges = this.radRichTextEditor1.Document.GetContainingAnnotationRanges<BookmarkRangeStart>(inline);

```

```VB.NET
Dim isInRange As Boolean = Me.radRichTextEditor1.Document.IsInAnnotationRange(Of BookmarkRangeStart)(inline)

Dim ranges As IEnumerable(Of BookmarkRangeStart) = Me.radRichTextEditor1.Document.GetContainingAnnotationRanges(Of BookmarkRangeStart)(inline)

```

* More finely tuned methods that filter the annotation ranges at the time of their retrieval include:

```C#
bool isInRange1 = this.radRichTextEditor1.Document.IsInAnnotationRange<BookmarkRangeStart>(inline, Filter, true);

IEnumerable<BookmarkRangeStart> ranges1 = this.radRichTextEditor1.Document.GetContainingAnnotationRanges<BookmarkRangeStart>(inline, Filter, true);

```

```VB.NET
Dim isInRange1 As Boolean = Me.radRichTextEditor1.Document.IsInAnnotationRange(Of BookmarkRangeStart)(inline, AddressOf Filter, True)

Dim ranges1 As IEnumerable(Of BookmarkRangeStart) = Me.radRichTextEditor1.Document.GetContainingAnnotationRanges(Of BookmarkRangeStart)(inline, AddressOf Filter, True)

```

## Inserting Annotations

Annotations can be inserted in the document using the following method of [RadDocumentEditor](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/features/raddocumenteditor).

```C#
documentEditor.InsertAnnotationRange(new BookmarkRangeStart(), new BookmarkRangeEnd());

```

```VB.NET
documentEditor.InsertAnnotationRange(New BookmarkRangeStart(), New BookmarkRangeEnd())

```

There are also some methods that insert specific types of annotations for the commonly used types, such as Hyperlinks, Comments, etc. For more information, check the respective article.

## Deleting Annotations

In order to delete an annotation, you need to obtain a reference to its range start first. After that, you can use the following method of [RadDocumentEditor](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/features/raddocumenteditor) to remove it.

```C#
documentEditor.DeleteAnnotationRange(start);

```

```VB.NET
documentEditor.DeleteAnnotationRange(start)

```

Note that this method will remove the annotation, but will keep its contents. In order to delete the contents as well, you can select it and use the **Delete** method of the editor:

```C#
documentEditor.Document.Selection.SelectAnnotationRange(start);
documentEditor.Delete(false);

```

```VB.NET
documentEditor.Document.Selection.SelectAnnotationRange(start)
documentEditor.Delete(False)

```

There are also some methods that remove specific types of annotations for the commonly used types, such as **Hyperlinks**, **Comments**, etc. For more information, check the respective article.

## Splitting Annotations

Some user scenarios require that there would be an easy way to split annotation ranges. In such cases, one can use the following methods:

```C#
documentEditor.SplitAnnotationRange(start);
//or
documentEditor.SplitAnnotationRange(start, documentPosition);

```

```VB.NET
documentEditor.SplitAnnotationRange(start)
'or
documentEditor.SplitAnnotationRange(start, documentPosition)

```

## See Also

* [Annotations](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/annotations/overview)

* [Custom Annotations](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/annotations/custom-annotations)
