.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

Comment.Text Property

Specifies the text of a comment.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v21.2.Core.dll


string Text { get; set; }

Property Value

Type Description

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


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®).


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