# Adding a Comment to a Cell

Learn how to add comments and notes to cells in a worksheet with Spread for WinForms. Find out how to enable the EnhancedShapeEngine property and modify the added comment using code examples.

## Content

Spread for WinForms supports adding comments to cells in a worksheet. You can add a plain text comment or note by referring to the [Adding a Note to a Cell](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssobject-cell/spwin-cell-note) topic.
Additionally, you can enable the **EnhancedShapeEngine** property to add a string or RichText instances by using the [IRange.AddComment](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.IRange.AddComment.html) method.
You can modify the added comment by using the [IRange.Comment](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.IRange.Comment.html) property. For example, the image below shows a default comment as well as a customized comment. The customized comment is set to always be visible and has shape properties such as background color, shape border style, and border color.
![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/comment-richtext-custom.png)
The following code shows how to set comments.

```csharp
// Get activesheet
GrapeCity.Spreadsheet.IWorksheet TestActiveSheet = fpSpread1.AsWorkbook().ActiveSheet;
           
// Enable enhanced shape engine
fpSpread1.Features.EnhancedShapeEngine = true;
           
string username = "Admin" + ":";
           
// Initilize richtext object
GrapeCity.Spreadsheet.RichText richText = new GrapeCity.Spreadsheet.RichText(username + "\r\nThis is a rich text \r\nsupported comment");
// Setting style
GrapeCity.Spreadsheet.Font font = GrapeCity.Spreadsheet.Font.Empty;
font.Bold = true;
GrapeCity.Spreadsheet.Font font2 = GrapeCity.Spreadsheet.Font.Empty;
font2.Italic = true;
font2.Underline = GrapeCity.Spreadsheet.UnderlineStyle.Double;
// Adding style to rich text
richText.Format(0, username.Length, font);
richText.Format(17, 9, font2);
// Adding a comment to cell
GrapeCity.Spreadsheet.IComment comment = TestActiveSheet.Cells["B2"].AddComment(richText);
           
// Customizing comment style
TestActiveSheet.Cells["B2"].Comment.Visible = true; // Always show comment
TestActiveSheet.Cells["B2"].Comment.Shape.Fill.BackColor.ARGB = Color.Orange.ToArgb();  // Change comment background color
TestActiveSheet.Cells["B2"].Comment.Shape.Line.Style = GrapeCity.Drawing.LineStyle.ThickThin;   // Change border style
TestActiveSheet.Cells["B2"].Comment.Shape.Line.Weight = 5;  // Change border thickness
TestActiveSheet.Cells["B2"].Comment.Shape.Line.ForeColor.ARGB = Color.DeepSkyBlue.ToArgb(); // Change border color
```

```vbnet
'Get activesheet
Dim TestActiveSheet As GrapeCity.Spreadsheet.IWorksheet = FpSpread1.AsWorkbook().ActiveSheet
       
'Enable enhanced shape engine
FpSpread1.Features.EnhancedShapeEngine = True
Dim username As String = "Admin" & ":"
'Initilize richtext object
Dim richText As GrapeCity.Spreadsheet.RichText = New GrapeCity.Spreadsheet.RichText(username & vbCrLf & "This is a rich text " & vbCrLf & "supported comment")
'Setting style
Dim font As GrapeCity.Spreadsheet.Font = GrapeCity.Spreadsheet.Font.Empty
font.Bold = True
Dim font2 As GrapeCity.Spreadsheet.Font = GrapeCity.Spreadsheet.Font.Empty
font2.Italic = True
font2.Underline = GrapeCity.Spreadsheet.UnderlineStyle.Double
'Adding style to rich text
richText.Format(0, username.Length, font)
richText.Format(17, 9, font2)
'Adding a comment to cell
Dim comment As GrapeCity.Spreadsheet.IComment = TestActiveSheet.Cells("B2").AddComment(richText)
'Customizing comment style
TestActiveSheet.Cells("B2").Comment.Visible = True  'Always show comment
TestActiveSheet.Cells("B2").Comment.Shape.Fill.BackColor.ARGB = Color.Orange.ToArgb()   'Change comment background color
TestActiveSheet.Cells("B2").Comment.Shape.Line.Style = GrapeCity.Drawing.LineStyle.ThickThin    'Change border style
TestActiveSheet.Cells("B2").Comment.Shape.Line.Weight = 5   'Change border thickness
TestActiveSheet.Cells("B2").Comment.Shape.Line.ForeColor.ARGB = Color.DeepSkyBlue.ToArgb()  'Change border color
```

## Threaded Comments

Users can view threaded comments in the Spread UI. This helps in connecting several comments together and presenting a virtual conversation in the workbook.
![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/comment-threaded.png)
**Using Code**
You can add threaded comments by using the [IRange.AddCommentThreaded](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.IRange.AddCommentThreaded.html) method.

```csharp
// Threaded comments
fpSpread1.LegacyBehaviors = LegacyBehaviors.None;
fpSpread1.Features.EnhancedShapeEngine = true;
fpSpread1.AsWorkbook().TestActiveSheet.Cells["C5"].AddCommentThreaded("Threaded comment supported").AddReply("First reply");
```

```vbnet
' Threaded comments
FpSpread1.LegacyBehaviors = LegacyBehaviors.None
FpSpread1.Features.EnhancedShapeEngine = True
FpSpread1.AsWorkbook().TestActiveSheet.Cells("C5").AddCommentThreaded("Threaded comment supported").AddReply("First reply")
```

## Gradient Fill Effects

You can add gradient effects to emphasize the comments by applying fill-color and patterns.
![comment-gradient](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/comment-gradient.png)
**Using Code**
To add the gradient effects, use the **Fill** property of the **IShapeBase** interface, which gets an object of the **IFillFormat** interface for a specified shape that contains the fill formatting properties for shape.

```csharp
fpSpread1.Features.EnhancedShapeEngine = true;
IWorksheet TestActiveSheet = fpSpread1.AsWorkbook().ActiveSheet;
IShape shape;
shape = TestActiveSheet.Cells["A1"].AddComment("InsetPen = false").Shape;
TestActiveSheet.Cells["A1"].Comment.Visible = true;
shape.Fill.OneColorGradient(GrapeCity.Spreadsheet.Drawing.GradientStyle.FromCenter, 1, 1);
shape.Fill.GradientStops.Delete(0);
shape.Fill.GradientStops.Delete(0);
shape.Fill.GradientStops.Delete(0);
shape.Fill.GradientStops.Insert(0xffff00, 0);
shape.Fill.GradientStops.Insert(0xffffff, 0.5);
shape.Fill.GradientStops.Insert(0x00ffff, 1);
shape.Fill.GradientStops[0].Color.SchemeColor = 23;
shape.Fill.PathShadeType = GrapeCity.Drawing.PathShadeType.Shape;
IShape aa = fpSpread1.AsWorkbook().ActiveSheet.Cells["A1"].Comment.Shape;
```

```vbnet
FpSpread1.Features.EnhancedShapeEngine = True
IWorksheet TestActiveSheet = FpSpread1.AsWorkbook().ActiveSheet
Dim shape As IShape
shape = TestActiveSheet.Cells("A1").AddComment("InsetPen = false").Shape
TestActiveSheet.Cells("A1").Comment.Visible = True
shape.Fill.OneColorGradient(GrapeCity.Spreadsheet.Drawing.GradientStyle.FromCenter, 1, 1)
shape.Fill.GradientStops.Delete(0)
shape.Fill.GradientStops.Delete(0)
shape.Fill.GradientStops.Delete(0)
shape.Fill.GradientStops.Insert(0xffff00, 0)
shape.Fill.GradientStops.Insert(0xffffff, 0.5)
shape.Fill.GradientStops.Insert(0x00ffff, 1)
shape.Fill.GradientStops(0).Color.SchemeColor = 23
shape.Fill.PathShadeType = GrapeCity.Drawing.PathShadeType.Shape
Dim aa As IShape =  FpSpread1.AsWorkbook().ActiveSheet.Cells("A1").Comment.Shape
```

**Using Runtime UI**
You can add or manipulate gradient fill effects at run time via the **Fill Effects** dialog. The Fill Effects dialog provides options like colors, variants, shading styles, patterns, and a sample preview to view the gradient effect.
![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/comment-fill-effect.gif)
To invoke the dialog at runtime, select the comment on the sheet and use the keyboard shortcut keys combination Ctrl+1, or select the **Format Comment** option from the built-in context menu.
In the **Format Comments** dialog, navigate to the **Colors and Lines** tab and select the **Fill Effects** option from the Color picker dropdown to view the **Fill Effects** dialog.

>type=note
> **Note:** For the keyboard shortcut to work, set the **ExcelCompatibleKeyboardShortcuts** property to true.

You can also invoke the Fill Effects dialog at runtime using the **FillEffects** method of the **BuiltInDialogs** class. To learn more about this class, see [Working with BuiltIn Dialogs](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-ssojbects/work-with-builtin-dialog).
**Using Spread Designer**
To view comments and add gradient effects to the block in the Spread Designer, follow the below mentioned steps:

1. Set the **EnhancedShapeEngine** and **ExcelCompatibleKeyboardShortcuts** to true in the properties window.
2. Select the comment on which you want to add or modify the gradient effect.
3. Invoke the **Format Comment** dialog.
4. Click the **Fill Effects** button from the **Colors and Lines** tab to open the **Fill Effects** dialog.

## Text Orientation

Formatting text in the comments is helpful for customizing the appearance and readability of comments or notes in the worksheet, allowing you to visually display your annotations in a more appealing way. Usually, Spread allows you to orient the text horizontally or vertically. However, using the **HorizontalRotatedFarEast** property of [TextOrientation](/spreadnet/api/latest/online-win/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.Drawing.TextOrientation.html) enumeration, you can control the orientation and formatting of text within cell comments. This property allows you to stack text vertically.
![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/textdirection_cellnote.png)

>type=note
> **Note:** The implementation of this feature takes effect only if the **EnhancedShapeEngine** property is set to true.

**Using code**
The following example code shows how to change text orientation in cell comments.

```csharp
// Add support paint stacked text direction for cell comment
fpSpread1.Features.EnhancedShapeEngine = true;
var activeSheet = fpSpread1.AsWorkbook().ActiveSheet;
var comment = activeSheet.Cells["A1"].AddComment("Vertical\n text");
comment.Shape.TextFrame.Orientation = GrapeCity.Spreadsheet.Drawing.TextOrientation.HorizontalRotatedFarEast;
comment.Shape.TextFrame.WordWrap = true;
comment.Shape.Height = 200;
comment.Visible = true;
var comment2 = activeSheet.Cells["C1"].AddComment("Vertical text in comment");
comment2.Shape.TextFrame.Orientation = GrapeCity.Spreadsheet.Drawing.TextOrientation.HorizontalRotatedFarEast;
comment2.Shape.TextFrame.WordWrap = true;
comment2.Shape.Height = 200;
comment2.Visible = true;
var comment3 = activeSheet.Cells["E1"].AddComment("abc");
comment3.Shape.TextFrame.Orientation = GrapeCity.Spreadsheet.Drawing.TextOrientation.HorizontalRotatedFarEast;
comment3.Shape.TextFrame.HorizontalAlignment = GrapeCity.Spreadsheet.HorizontalAlignment.Justify;
comment3.Shape.TextFrame.VerticalAlignment = GrapeCity.Spreadsheet.VerticalAlignment.Justify;
comment3.Shape.Height = 40;
comment3.Visible = true;
```

```vbnet
' Add support paint stacked text direction for cell comment
FpSpread1.Features.EnhancedShapeEngine = True
Dim activeSheet = FpSpread1.AsWorkbook().ActiveSheet
    
Dim comment = activeSheet.Cells("A1").AddComment("Vertical" & vbLf & " text")
comment.Shape.TextFrame.Orientation = GrapeCity.Spreadsheet.Drawing.TextOrientation.HorizontalRotatedFarEast
comment.Shape.TextFrame.WordWrap = True
comment.Shape.Height = 200
comment.Visible = True
Dim comment2 = activeSheet.Cells("C1").AddComment("Vertical text in comment")
comment2.Shape.TextFrame.Orientation = GrapeCity.Spreadsheet.Drawing.TextOrientation.HorizontalRotatedFarEast
comment2.Shape.TextFrame.WordWrap = True
comment2.Shape.Height = 200
comment2.Visible = True
Dim comment3 = activeSheet.Cells("E1").AddComment("abc")
comment3.Shape.TextFrame.Orientation = GrapeCity.Spreadsheet.Drawing.TextOrientation.HorizontalRotatedFarEast
comment3.Shape.TextFrame.HorizontalAlignment = GrapeCity.Spreadsheet.HorizontalAlignment.Justify
comment3.Shape.TextFrame.VerticalAlignment = GrapeCity.Spreadsheet.VerticalAlignment.Justify
comment3.Shape.Height = 40
comment3.Visible = True
```

**At Runtime**
Using the **Format Comment** dialog, you can change the orientation of the comments you have added to cells. To invoke the dialog at runtime, perform the following steps:

1. Run the code below to load a spread control with a comment.

    ```csharp
    fpSpread1.Features.EnhancedShapeEngine = true;
    var activeSheet = fpSpread1.AsWorkbook().ActiveSheet;
    var comment = activeSheet.Cells["A1"].AddComment("Vertical text");
    comment.Shape.TextFrame.Orientation = GrapeCity.Spreadsheet.Drawing.TextOrientation.HorizontalRotatedFarEast;
    comment.Visible = true;
    ```

    ```vbnet
    FpSpread1.Features.EnhancedShapeEngine = True
    Dim activeSheet = FpSpread1.AsWorkbook().ActiveSheet
    Dim comment = activeSheet.Cells("A1").AddComment("Vertical text")
    comment.Shape.TextFrame.Orientation = GrapeCity.Spreadsheet.Drawing.TextOrientation.HorizontalRotatedFarEast
    comment.Visible = True
    ```


2\. Right\-click on the comment to open up the **Format Comment…** context menu.
3\. Select the **Alignment** tab.
4\. Select the **Orientation** as per your choice and click **OK**.

![](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/formatcomments_dialog.png)