SpreadsheetControl.CustomDrawCommentIndicator Event
Allows you to customize comment indicators.
Namespace: DevExpress.XtraSpreadsheet
Assembly: DevExpress.XtraSpreadsheet.v24.1.dll
NuGet Package: DevExpress.Win.Spreadsheet
Declaration
Event Data
The CustomDrawCommentIndicator event's data class is CustomDrawCommentIndicatorEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cache | Gets an object that serves as the storage for pens, fonts and brushes. Inherited from CustomDrawObjectEventsArgs. |
Cell | Gets a cell that contains a comment indicator being pained. |
CellBounds | Returns the cell’s boundaries, excluding cell borders. |
ForeColor | Gets or sets the color of the default comment indicator. |
Graphics | Gets an object used for painting. Inherited from CustomDrawObjectEventsArgs. |
Handled | Gets or sets whether an event is handled. If true, the default actions are not required. Inherited from CustomDrawObjectEventsArgs. |
Size | Gets or sets the size of the default comment indicator in units of measurement that are currently in effect. |
The event data class exposes the following methods:
Method | Description |
---|---|
DrawDefault() | Renders the element using the default drawing mechanism. Inherited from CustomDrawObjectEventsArgs. |
Remarks
The CustomDrawCommentIndicator event fires for each visible cell that has a comment and allows you to paint comment indicators in a custom manner.
If you manually draw the indicators, set the event’s CustomDrawObjectEventsArgs.Handled parameter to true. To display the standard comment indicator, call the CustomDrawObjectEventsArgs.DrawDefault method.
The following examples demonstrate how to handle the CustomDrawCommentIndicator event to change the appearance of comment indicators.
Change the default comment indicator’s size and color
You can use the event’s Size and ForeColor properties to change the size and color of the standard comment indicator.
spreadsheetControl1.CustomDrawCommentIndicator += (s, e) => {
e.Size = 10;
e.ForeColor = Color.FromArgb(0x21, 0x73, 0x46);
};
Change a comment indicator’s shape
The code snippet below shows how to use the e.Cache.FillRectangle method to display a square comment indicator.
spreadsheetControl1.CustomDrawCommentIndicator += (s, e) => {
int size = e.Size;
e.Cache.FillRectangle(e.Cache.GetSolidBrush(Color.FromArgb(0x21, 0x73, 0x46)), e.CellBounds.Right - size, e.CellBounds.Top, size, size);
e.Handled = true;
};
Display an image as a comment indicator
The code snippet below shows how to use the e.Cache.DrawImage method to display an image instead of a comment indicator.
Image commentImage = Image.FromFile("Comment.png");
spreadsheetControl1.CustomDrawCommentIndicator += (s, e) => {
e.Cache.DrawImage(commentImage, e.CellBounds.Right - commentImage.Width, e.CellBounds.Top);
e.Handled = true;
};