Home › Forums › WinForms controls › Xceed Grid for WinForms › PaintForeground doesn’t fire for inherited DataCell when the datatype is not System.String
-
AuthorPosts
-
#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 DataCellPrivate mSelected As Boolean
Public Property Selected() As Boolean
Get
Return mSelected
End Get
Set(ByVal Value As Boolean)
If mSelected = Value Then
Return
End IfmSelected = Value
‘ Force the cell to be redrawn.
Me.Invalidate()
End Set
End PropertyProtected Sub New(ByVal template As SelectableCell)
MyBase.New(template)mSelected = template.mSelected
End SubPublic Sub New(ByVal parentColumn As Column)
MyBase.New(parentColumn)‘mSelected = False
End SubProtected Overrides Function CreateInstance() As Cell
Return New SelectableCell(Me)
End FunctionProtected Overrides Sub PaintForeground(ByVal e As GridPaintEventArgs)
MyBase.PaintForeground(e)If mSelected Then
Dim myBrush As BrushmyBrush = 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 ClassSelectableRow
Imports System
Imports Xceed.Grid”’ <summary>
”’ Based on the ImageRow class in the Xceed Puzzle example
”’ </summary>
”’ <remarks></remarks>
Public Class SelectableRow
Inherits DataRowPublic Sub New()
MyBase.New()
End SubPublic Sub New(ByVal rowSelector As RowSelector)
MyBase.New(rowSelector)
End SubProtected Sub New(ByVal template As SelectableRow)
MyBase.New(template)
End SubProtected Overrides Function CreateCell(ByVal parentColumn As Column) As Cell
Return New SelectableCell(parentColumn)
End FunctionProtected Overrides Function CreateInstance() As Row
Return New SelectableRow(Me)
End FunctionProtected Overrides ReadOnly Property DefaultCanBeSelected() As Boolean
Get
Return False
End Get
End Property
End ClassCall to grid to set the SelectableRow
grdSelectable.DataRowTemplate = New SelectableRow
Imported from legacy forums. Posted by Christian (had 568 views)
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)
-
AuthorPosts
- You must be logged in to reply to this topic.