Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Excel like comment indicator on Cells


we have requirement to display an Excel like comment corner marker on the ultragrid cells. I know there isn't a built in way and I need to use a draw filter or a creation filter but I am not sure how exactly to get the bounds on the UIElements rectangle and what I need to draw/create in order to show the Excel like comment marker.

I have used the following code that I got from one of the forums:


 Private Function IUIElementDrawFilter_DrawElement(drawPhase As DrawPhase, ByRef drawParams As UIElementDrawParams) As Boolean Implements IUIElementDrawFilter.DrawElement

        If TypeOf drawParams.Element Is CellUIElement Then

            Dim cell = TryCast(drawParams.Element.GetContext(GetType(UltraGridCell), True), UltraGridCell)

            If cell IsNot Nothing AndAlso cell.Column.Index <> 0 AndAlso cell.Tag IsNot Nothing Then

                Using blueBrush As New SolidBrush(If(cell.Column.Index Mod 2 = 0, Color.Blue, Color.Red))

                    Dim rect = drawParams.Element.RectInsideBorders


                    ' Create points that define polygon.

                    Dim point1 As New Point(rect.X + rect.Width * 7 / 8, rect.Y)

                    Dim point2 As New Point(rect.X + rect.Width, rect.Y)

                    Dim point3 As New Point(rect.X + rect.Width, rect.Y + rect.Height / 4)

                    Dim curvePoints As Point() = {point1, point2, point3}


                    ' Draw polygon to screen.

                    drawParams.Graphics.FillPolygon(blueBrush, curvePoints)

                    'drawParams.DrawFocusRectangle(rect, Color.Red, Color.Red)

                    'drawParams.DrawBorders(UIElementBorderStyle.Raised, Border3DSide.All, rect)

                    'drawParams.DrawArrowIndicator(ScrollButton.Left, rect, UIElementButtonState.StateButtonDown)

                End Using

            End If


            Return True

        End If


        Return False


    End Function

I am drawing a polygon but that looks very rough and does not exactly sit on the top right corner. also when I resize the cells this just goes bad. I want the size to be constant.


Thanks in advance




Nasir Amin