New to Telerik UI for WinForms? Download free 30-day trial


RadRichTextEditor control provides functionality for inserting comment annotations inside the document. You can programmatically insert and delete comments though the RadDocumentEditor class.

UI and Commands

Commenting functionality is available in the Review tab inside the RadRichTextEditorRibbonUI example:

WinForms RadRichTextEditor Comments Options

The following commands related to the commenting functionality are available in the Commands property of the RadRichTextEditor:

  • InsertCommentCommand: Adds a comment about the current selection.

  • DeleteCommentCommand: Deletes the selected comment.

  • DeleteAllCommentsCommand: Deletes all of the comments in the document.

  • GoToPreviousCommentCommand: Navigates to the previous comment in the document.

  • GoToNextCommentCommand: Navigate to the next comment in the document.

  • ToggleCommentsCommand: Toggles comments visibility.

In order to learn more about commands and how to use them refer to this article.

Working with Comments Programmatically

Comments inside the RadDocument model are implemented using the CommentRangeStart and CommentRangeEnd annotations. The actual Comment object which contains the content of the comment is a property of the CommentRangeEnd.

Comments can be programmatically inserted/deleted using the following methods of RadDocumentEditor:

  • public void InsertComment(Comment comment)

  • public void DeleteComment()

  • public void DeleteComment(CommentRangeStart commentRangeStart)

  • DeleteAllComments()

Note, that these methods work with the current position and selection in the document.

You can also programmatically navigate and select comments using the API of RadDocument:

  • public CommentRangeStart GetNextComment()

  • public CommentRangeStart GetPreviousComment()

  • public CommentRangeStart GoToNextComment()

  • public CommentRangeStart GoToPreviousComment()

  • public void GoToComment(Comment comment)

  • public void GoToComment(CommentRangeStart commentRangeStart)

  • public CommentRangeStart GetCommentRangeStartByComment(Comment comment)

There are also GoToNextComment() and GoToPreviousComment() methods available in RadRichTextEditor. They select the appropriate comment and place the focus inside the comment balloon if the comments are visible. These methods also show a message box if no comment is found.

Customizing Visualization

You can customize the looks of the comments by attaching to the CommentShowing event of RadRichTextEditor. Inside the event handler you can access the Comment and modify the AppearanceSettings that are used to visualize the comment. Here is an example:

private void radRichTextEditor1_CommentShowing(object sender, Telerik.WinForms.Documents.UI.CommentShowingEventArgs e)
    if (e.Comment.Author == "Boss")
        e.AppearanceSettings.BorderBrush = System.Drawing.Brushes.Red;
        e.AppearanceSettings.BackgroundBrush = System.Drawing.Brushes.Orange;
        e.AppearanceSettings.HighlightColor = Telerik.WinControls.RichTextEditor.UI.Colors.Orange;
        e.AppearanceSettings.BorderBrush = System.Drawing.Brushes.Green;
        e.AppearanceSettings.BackgroundBrush = System.Drawing.Brushes.LightGray;
        e.AppearanceSettings.HighlightColor = Telerik.WinControls.RichTextEditor.UI.Colors.LightGray;

Private Sub radRichTextEditor1_CommentShowing(ByVal sender As Object, ByVal e As Telerik.WinForms.Documents.UI.CommentShowingEventArgs)
    If e.Comment.Author = "Boss" Then
        e.AppearanceSettings.BorderBrush = System.Drawing.Brushes.Red
        e.AppearanceSettings.BackgroundBrush = System.Drawing.Brushes.Orange
        e.AppearanceSettings.HighlightColor = Telerik.WinControls.RichTextEditor.UI.Colors.Orange
        e.AppearanceSettings.BorderBrush = System.Drawing.Brushes.Green
        e.AppearanceSettings.BackgroundBrush = System.Drawing.Brushes.LightGray
        e.AppearanceSettings.HighlightColor = Telerik.WinControls.RichTextEditor.UI.Colors.LightGray
    End If
End Sub

And the result looks like this:

WinForms RadRichTextEditor Comments Review

Note, that for performance reasons this event will be thrown only once per each comment – the first time it is shown. The AppearanceSettings will then be cached and used for the associated comment when needed.

See Also

In this article