Back to Devexpress

CommentCollection.Create(DocumentRange, String, DateTime) Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-commentcollection-dot-create-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-documentrange-system-dot-string-system-dot-datetime-x29.md

latest6.9 KB
Original Source

CommentCollection.Create(DocumentRange, String, DateTime) Method

Creates a comment for the specified range and assigns the author’s name and creation date.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
Comment Create(
    DocumentRange range,
    string author,
    DateTime date
)
vb
Function Create(
    range As DocumentRange,
    author As String,
    date As Date
) As Comment

Parameters

NameTypeDescription
rangeDocumentRange

A DocumentPosition that specifies the start of the range being commented.

| | author | String |

A string that specifies the comment’s author.

| | date | DateTime |

A DateTime object that specifies the comment creation date.

|

Returns

TypeDescription
Comment

A Comment object successfully created.

|

Remarks

The created comment is added to the SubDocument.Comments collection automatically .

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

The following code snippets (auto-collected from DevExpress Examples) contain references to the Create(DocumentRange, String, DateTime) 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-document-api/CS/RichEditAPISample/CodeExamples/Comments.cs#L13

csharp
string commentAuthor = "Johnson Alphonso D";
document.Comments.Create(docRange, commentAuthor, DateTime.Now);
#endregion #CreateComment

wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/CommentsActions.cs#L22

csharp
string commentAuthor = "Maryland B. Clopton";
document.Comments.Create(docRange, commentAuthor, DateTime.Now);
#endregion #CreateComment

word-document-api-examples/CS/CodeExamples/CommentsActions.cs#L38

csharp
// Create a comment.
    document.Comments.Create(docRange, commentAuthor, DateTime.Now);
}

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Comments.vb#L13

vb
Dim commentAuthor As String = "Johnson Alphonso D"
            document.Comments.Create(docRange, commentAuthor, System.DateTime.Now)
#End Region ' #CreateComment

wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/CommentsActions.vb#L20

vb
Dim commentAuthor As String = "Maryland B. Clopton"
            document.Comments.Create(docRange, commentAuthor, DateTime.Now)
' #End Region ' #CreateComment

word-document-api-examples/VB/CodeExamples/CommentsActions.vb#L36

vb
' Create a comment.
    document.Comments.Create(docRange, commentAuthor, System.DateTime.Now)
End If

See Also

CommentCollection Interface

CommentCollection Members

DevExpress.XtraRichEdit.API.Native Namespace