officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-765a9348.md
A comment in the document - a text note that is attached to a DocumentRange.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
[ComVisible(true)]
public interface Comment
<ComVisible(True)>
Public Interface Comment
The following members return Comment objects:
Comments are contained in the CommentCollection, which is accessed by the SubDocument.Comments property.
Use the CommentCollection.Create to create a new comment with the specified settings.
Note
When the user adds a comment from the User Interface, the comment’s author is obtained from the CommentOptions.Author property.
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);
}
}
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