Skip to main content
Row

Comment.Text Property

Specifies the text of a comment.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v24.1.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

string Text { get; set; }

Property Value

Type Description
String

A String value that specifies the text to be displayed in the comment box.

Remarks

Comment text is grouped into one or more runs. Each run is specified by the CommentRun object and defines a region of the comment text (CommentRun.Text) with its own set of font characteristics (CommentRun.Font). Comment runs are stored in the CommentRunCollection collection that is accessed via the Comment.Runs property.

When you create a new comment via the CommentCollection.Add method or set the Text of an existing comment, the CommentRunCollection collection includes a single run that holds the full text of the comment formatted with the default font. To change the font of the comment text, access this run object and use its CommentRun.Font property to get and modify the SpreadsheetFont object. For example, the following code snippet demonstrates how to change the font style of the comment text.

using DevExpress.Spreadsheet;
// ...

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
Cell cell = worksheet.Cells["B3"];

//Add a comment to a cell.
Comment comment = worksheet.Comments.Add(cell, workbook.CurrentAuthor, "Comment Text");
// Format comment text as bold and italic.
comment.Runs[0].Font.FontStyle = DevExpress.Spreadsheet.SpreadsheetFontStyle.BoldItalic;

The image below shows the comment with formatted text (the workbook is opened in Microsoft® Excel®).

Comment_Text_Formatted

To divide the comment text into regions formatted with different fonts, add the corresponding runs into the CommentRunCollection object. For an example, refer to the How to: Add a Comment To a Cell document.

If there are several runs within the comment text, the Text property returns a string that combines all text regions specified by these runs.

See Also