Home Forums WinForms controls Xceed Grid for WinForms Cell comment icon like in Excel Reply To: Cell comment icon like in Excel

User (Old forums)
Post count: 23064

Here is what I ended up with and it works great.  I think this is easier that creating a new derived class.

This is Friend only because for me it is in a base class, could be private or public or whatever you need.
Hook this to the Cell.Paint event for each of the cells in the DataRowTemplate.Cells collection.

You will need to include your own check in the sub for which cell gets the indicator, used as is it will put the graphic in every cell.  I did not include the check since mine may not be like yours.

I hope this helps someone else….

For Each oCell As Xceed.Grid.Cell In mGridControl.DataRowTemplate.Cells
    AddHandler oCell.Paint, AddressOf AddCommentIndicator

     Friend Sub AddCommentIndicator(ByVal sender As Object, ByVal e As Xceed.Grid.GridPaintEventArgs)

        ‘Wrap the following in the conditional for you situation where you want the indicator drawn.
        Dim CellBrush As New SolidBrush(Color.Red)
            Dim TrianglePoints() As System.Drawing.PointF = {New PointF(e.DisplayRectangle.Right – 5, e.DisplayRectangle.Y), New PointF(e.DisplayRectangle.Right, e.DisplayRectangle.Y), New PointF(e.DisplayRectangle.Right + 5, e.DisplayRectangle.Y + 10)}
            e.Graphics.DrawPolygon(Pens.Red, TrianglePoints)
            e.Graphics.FillPolygon(CellBrush, TrianglePoints)
        Catch ex As Exception
        End Try

    End Sub

Imported from legacy forums. Posted by Brian (had 2536 views)