Hi All,
I am implementing the Paint Method override described in the Help
(DataGridTextBo xColumn.PaintMe thod). 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.HitTes tInfo
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.HitTes tType.Cell Then
' If it's a cell, get the GridTable and ListManager of the
' clicked table.
Dim dgt As DataGridTableSt yle = grid.TableStyle s(0)
'Dim cm As CurrencyManager = CType(Me.Bindin gContext _
'(MyDataSet.Tab les(dgt.Mapping Name)), CurrencyManager )
Dim cm As CurrencyManager = CType(Me.Bindin gContext _
(grid.DataSourc e, grid.DataMember ), CurrencyManager )
' Get the Rectangle of the clicked cell.
Dim cellRect As Rectangle
cellRect = grid.GetCellBou nds(hi.Row, hi.Column)
' Get the clicked DataGridTextBox Column.
Dim gridCol As MyGridColumn = CType _
(dgt.GridColumn Styles(hi.Colum n), MyGridColumn)
' Get the Graphics object for the form.
Dim g As Graphics = grid.CreateGrap hics()
' Create two new Brush objects: a fore brush and back brush.
Dim fBrush As New SolidBrush(Colo r.Blue)
Dim bBrush As New SolidBrush(Colo r.Yellow)
' Invoke the Paint method to paint the cell with the brushes.
gridCol.PaintCo l(g, cellRect, cm, hi.Row, bBrush, fBrush, False)
End If
End Sub
--
I am implementing the Paint Method override described in the Help
(DataGridTextBo xColumn.PaintMe thod). 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.HitTes tInfo
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.HitTes tType.Cell Then
' If it's a cell, get the GridTable and ListManager of the
' clicked table.
Dim dgt As DataGridTableSt yle = grid.TableStyle s(0)
'Dim cm As CurrencyManager = CType(Me.Bindin gContext _
'(MyDataSet.Tab les(dgt.Mapping Name)), CurrencyManager )
Dim cm As CurrencyManager = CType(Me.Bindin gContext _
(grid.DataSourc e, grid.DataMember ), CurrencyManager )
' Get the Rectangle of the clicked cell.
Dim cellRect As Rectangle
cellRect = grid.GetCellBou nds(hi.Row, hi.Column)
' Get the clicked DataGridTextBox Column.
Dim gridCol As MyGridColumn = CType _
(dgt.GridColumn Styles(hi.Colum n), MyGridColumn)
' Get the Graphics object for the form.
Dim g As Graphics = grid.CreateGrap hics()
' Create two new Brush objects: a fore brush and back brush.
Dim fBrush As New SolidBrush(Colo r.Blue)
Dim bBrush As New SolidBrush(Colo r.Yellow)
' Invoke the Paint method to paint the cell with the brushes.
gridCol.PaintCo l(g, cellRect, cm, hi.Row, bBrush, fBrush, False)
End If
End Sub
--