Hi All,
I am implementing the Paint Method override described in the Help
(DataGridTextBoxColumn.PaintMethod). I believe that I have implemented the
procedure example displayed in the Help verbatim. I receive no errors, and
the debugger shows all of the code being executed, but my new color never
appears when I click on the cell of the grid.
Are there any general things I can look for besides things like making sure
my rectangle is not of infintesimally small size, etc? I am pasting the MS
code below.
Thanks,
Michael
Private Sub PaintCell(ByVal sender As Object, ByVal e As MouseEventArgs)
' Use the HitTest method to get a HitTestInfo object.
Dim hi As DataGrid.HitTestInfo
Dim grid As DataGrid = CType(sender, DataGrid)
hi = grid.HitTest(e.X, e.Y)
' Test if the clicked area was a cell.
If hi.Type = DataGrid.HitTestType.Cell Then
' If it's a cell, get the GridTable and ListManager of the
' clicked table.
Dim dgt As DataGridTableStyle = grid.TableStyles(0)
'Dim cm As CurrencyManager = CType(Me.BindingContext _
'(MyDataSet.Tables(dgt.MappingName)), CurrencyManager)
Dim cm As CurrencyManager = CType(Me.BindingContext _
(grid.DataSource, grid.DataMember), CurrencyManager)
' Get the Rectangle of the clicked cell.
Dim cellRect As Rectangle
cellRect = grid.GetCellBounds(hi.Row, hi.Column)
' Get the clicked DataGridTextBoxColumn.
Dim gridCol As MyGridColumn = CType _
(dgt.GridColumnStyles(hi.Column), MyGridColumn)
' Get the Graphics object for the form.
Dim g As Graphics = grid.CreateGraphics()
' Create two new Brush objects: a fore brush and back brush.
Dim fBrush As New SolidBrush(Color.Blue)
Dim bBrush As New SolidBrush(Color.Yellow)
' Invoke the Paint method to paint the cell with the brushes.
gridCol.PaintCol(g, cellRect, cm, hi.Row, bBrush, fBrush, False)
End If
End Sub
--