officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-commentcollection-dot-create-x28-system-dot-string-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-comment-x29.md
Creates a nested comment.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
Comment Create(
string author,
Comment parentComment
)
Function Create(
author As String,
parentComment As Comment
) As Comment
| Name | Type | Description |
|---|---|---|
| author | String |
A String value that sets the Comment.Author property.
| | parentComment | Comment |
A Comment object that is the parent comment.
|
| Type | Description |
|---|---|
| Comment |
A Comment object that is the nested comment
|
Use the Create method to create a nested comment and add it to the collection of comments in a document.
static void CreateNestedComment(RichEditDocumentServer wordProcessor) {
// Load a document from a file.
wordProcessor.LoadDocument("Documents\\Grimm.docx", DocumentFormat.Docx);
// Access a document.
Document document = wordProcessor.Document;
if (document.Comments.Count > 1)
{
// Create a new comment nested in the parent comment.
Comment newComment = document.Comments.Create("Vicars Anny", document.Comments[1]);
newComment.Date = DateTime.Now;
SubDocument commentDocument = newComment.BeginUpdate();
commentDocument.InsertText(commentDocument.Range.Start, "I agree");
newComment.EndUpdate(commentDocument);
}
}
Shared Sub CreateNestedComment(ByVal wordProcessor As RichEditDocumentServer)
' Load a document from a file.
wordProcessor.LoadDocument("Documents\Grimm.docx", DocumentFormat.Docx)
' Access a document.
Dim document As Document = wordProcessor.Document
If document.Comments.Count > 1 Then
' Create a new comment nested in the parent comment.
Dim newComment As Comment = document.Comments.Create("Vicars Anny", document.Comments(1))
newComment.Date = Date.Now
Dim commentDocument As SubDocument = newComment.BeginUpdate()
commentDocument.InsertText(commentDocument.Range.Start, "I agree")
newComment.EndUpdate(commentDocument)
End If
End Sub
The following code snippets (auto-collected from DevExpress Examples) contain references to the Create(String, Comment) 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#L24
if (resRanges.Length > 0) {
Comment newComment = document.Comments.Create("Vicars Anny", document.Comments[1]);
newComment.Date = DateTime.Now;
wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/CommentsActions.cs#L32
if (resRanges.Length > 0) {
Comment newComment = document.Comments.Create("Vicars Anny", document.Comments[1]);
newComment.Date = DateTime.Now;
word-document-api-examples/CS/CodeExamples/CommentsActions.cs#L55
// Create a new comment nested in the parent comment.
Comment newComment = document.Comments.Create("Vicars Anny", document.Comments[1]);
newComment.Date = DateTime.Now;
winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Comments.vb#L23
If resRanges.Length > 0 Then
Dim newComment As DevExpress.XtraRichEdit.API.Native.Comment = document.Comments.Create("Vicars Anny", document.Comments(1))
newComment.[Date] = System.DateTime.Now
wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/CommentsActions.vb#L30
If resRanges.Length > 0 Then
Dim newComment As Comment = document.Comments.Create("Vicars Anny", document.Comments(1))
newComment.Date = DateTime.Now
word-document-api-examples/VB/CodeExamples/CommentsActions.vb#L49
' Create a new comment nested in the parent comment.
Dim newComment As DevExpress.XtraRichEdit.API.Native.Comment = document.Comments.Create("Vicars Anny", document.Comments(1))
newComment.[Date] = System.DateTime.Now
See Also