Home Forums WinForms controls Xceed Grid for WinForms PaintForeground doesn’t fire for inherited DataCell when the datatype is not System.String

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16100 |

    I have basically copied the Puzzle demo so that I can implement a more Excel like grid including multiple selected cells etc.

    Everything works well when the columns have a datatype of System.String, but when I change the datatype to something else, System.Int32 for instance, I have found that the PaintForeground event does not seem to fire and hence the code I have to mark a selected cell does not run.

    The classes I use are as below:

    SelectableCell

    Imports System
    Imports System.Drawing
    Imports System.Drawing.Drawing2D
    Imports Xceed.Grid

    ”’ <summary>
    ”’ Based on the ImageCell class in the Xceed Puzzle example
    ”’ </summary>
    ”’ <remarks></remarks>
    Public Class SelectableCell
        Inherits DataCell

        Private mSelected As Boolean

        Public Property Selected() As Boolean
            Get
                Return mSelected
            End Get
            Set(ByVal Value As Boolean)
                If mSelected = Value Then
                    Return
                End If

                mSelected = Value
                ‘ Force the cell to be redrawn.
                Me.Invalidate()
            End Set
        End Property

        Protected Sub New(ByVal template As SelectableCell)
            MyBase.New(template)

            mSelected = template.mSelected
        End Sub

        Public Sub New(ByVal parentColumn As Column)
            MyBase.New(parentColumn)

            ‘mSelected = False
        End Sub

        Protected Overrides Function CreateInstance() As Cell
            Return New SelectableCell(Me)
        End Function

        Protected Overrides Sub PaintForeground(ByVal e As GridPaintEventArgs)
            MyBase.PaintForeground(e)

            If mSelected Then
                Dim myBrush As Brush

                myBrush = New HatchBrush(HatchStyle.LightDownwardDiagonal, Color.FromArgb(100, SystemColors.HighlightText), Color.FromArgb(50, SystemColors.Highlight))
                Try
                    e.Graphics.FillRectangle(myBrush, Me.ClientRectangle)
                Finally
                    myBrush.Dispose()
                End Try
            End If
        End Sub
    End Class

    SelectableRow

    Imports System
    Imports Xceed.Grid

    ”’ <summary>
    ”’ Based on the ImageRow class in the Xceed Puzzle example
    ”’ </summary>
    ”’ <remarks></remarks>
    Public Class SelectableRow
        Inherits DataRow

        Public Sub New()
            MyBase.New()
        End Sub

        Public Sub New(ByVal rowSelector As RowSelector)
            MyBase.New(rowSelector)
        End Sub

        Protected Sub New(ByVal template As SelectableRow)
            MyBase.New(template)
        End Sub

        Protected Overrides Function CreateCell(ByVal parentColumn As Column) As Cell
            Return New SelectableCell(parentColumn)
        End Function

        Protected Overrides Function CreateInstance() As Row
            Return New SelectableRow(Me)
        End Function

        Protected Overrides ReadOnly Property DefaultCanBeSelected() As Boolean
            Get
                Return False
            End Get
        End Property
    End Class

    Call to grid to set the SelectableRow

    grdSelectable.DataRowTemplate = New SelectableRow

    Imported from legacy forums. Posted by Christian (had 568 views)

    User (Old forums)
    Member
    Post count: 23064

    I have it working. I am overriding the PaintBackground instead. It must have something to do with the Numeric CellViewerManager

    Imported from legacy forums. Posted by Christian (had 1393 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.