Back to Devexpress

CommentCollection Interface

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-20223f3b.md

latest3.6 KB
Original Source

CommentCollection Interface

A collection of Comment objects.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
[ComVisible(true)]
public interface CommentCollection :
    ReadOnlyCommentCollection,
    ISimpleCollection<Comment>,
    IEnumerable<Comment>,
    IEnumerable,
    ICollection
vb
<ComVisible(True)>
Public Interface CommentCollection
    Inherits ReadOnlyCommentCollection,
             ISimpleCollection(Of Comment),
             IEnumerable(Of Comment),
             IEnumerable,
             ICollection

The following members return CommentCollection objects:

Remarks

Items in the CommentCollection are ordered and indexed in the same order as the ranges to which they belong. That is, a comment whose Comment.Range is closer to the beginning of the document has a lower index value.

When you add a new comment, the CommentOptions.Visibility property is set to Visible.

Example

View Example

csharp
using DevExpress.XtraRichEdit.API.Native;
using DevExpress.XtraRichEdit;

static void CreateComment(RichEditDocumentServer wordProcessor) {

    // Load a document from a file.
    wordProcessor.LoadDocument("Documents\\Grimm.docx");

    // Access a document.
    Document document = wordProcessor.Document;

    if (document.Paragraphs.Count > 2) {
        // Access the range of the third paragraph.
        DocumentRange docRange = document.Paragraphs[2].Range;

        // Specify the comment's author name.
        string commentAuthor = "Johnson Alphonso D";

        // Create a comment.
        document.Comments.Create(docRange, commentAuthor, DateTime.Now);
    }
}
vb
Imports DevExpress.XtraRichEdit.API.Native
Imports DevExpress.XtraRichEdit

Shared Sub CreateComment(ByVal wordProcessor As RichEditDocumentServer)
    ' Load a document from a file.
    wordProcessor.LoadDocument("Documents\Grimm.docx")

    ' Access a document.
    Dim document As Document = wordProcessor.Document

    If document.Paragraphs.Count > 2 Then
        ' Access the range of the third paragraph.
        Dim docRange As DocumentRange = document.Paragraphs(2).Range

        ' Specify the comment's author name.
        Dim commentAuthor As String = "Johnson Alphonso D"

        ' Create a comment.
        document.Comments.Create(docRange, commentAuthor, Date.Now)
    End If
End Sub

See Also

CommentCollection Members

Comments in Rich Text Documents

DevExpress.XtraRichEdit.API.Native Namespace