A note text region with its own set of font characteristics.
NuGet Package: DevExpress.Spreadsheet.Core
Simple note’s text is grouped into one or more runs. Each run is specified by the
CommentRun object and defines a region of the text (CommentRun.Text) with its own set of font characteristics (CommentRun.Font). The Comment.Runs property returns the CommentRunCollection collection that stores note runs. Use methods of the CommentRunCollection object to divide the note text into regions and specify font properties for each text region.
This example demonstrates how to add a simple note (a legacy comment) to a cell and format the note text.
Create a Simple Note
Format Note Content
To apply different fonts to specific regions of the comment text, modify the CommentRunCollection collection returned by the Comment.Runs property. This collection stores the CommentRun objects that define regions of the comment text that are formatted specifically. After a comment has been created, its text is defined by a single run that is contained in the CommentRunCollection collection.
using DevExpress.Spreadsheet; //... Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets; // Get the system username. string author = workbook.CurrentAuthor; // Add a comment to the A1 cell. Cell cell = worksheet.Cells["A1"]; Comment comment = worksheet.Comments.Add(cell, author, "This is important information for users."); //Add the author name at the beginning of the comment. CommentRunCollection runs = comment.Runs; runs.Insert(0, author + ": \r\n"); runs.Font.Bold = true; // Format the comment text. runs.Font.Color = Color.Red; runs.Font.Name = "Times New Roman"; runs.Font.Size = 14; runs.Font.Italic = true; // Add a new comment run. runs.Add("\n Never delete this comment!"); runs.Font.Color = Color.MidnightBlue;
Use the following methods to remove simple notes: