473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Paint a DataGrid Cell

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
--

Dec 22 '06 #1
0 1397

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: DraguVaso | last post by:
Hi, I 'wrote' my own DataGrid, using the normal DataGrid, and overriding some of the DataGridTextBoxColumn-methods (mostly the Paint-method). I based most of my changes on the Windows Form FAQ:...
2
by: DraguVaso | last post by:
Hi, In the override of the Paint-method of a DataGridTextBoxColumn I want to show an image with BitBlt, to see what I can gain there on performance. The problem is: It doesn't show me the image...
3
by: Mark.Larsen | last post by:
I made a class that extends DataGridColumnStyle. In the Paint override I draw a border around each cell in the column. All cells look fine except for the last one (final row). The lines I draw...
2
by: Daniel Walzenbach | last post by:
Hi, I created an ASP.NET Datagrid where a single row can be selected by clicking anywhere on the row (according to...
5
by: ruca | last post by:
Hi, Can anyone give me examples of how can I hightlight cells of my datagrid? I know that I must use ItemBound event and probably JavaScript. The thing is that I have a anual calendar,...
4
by: Suzanne | last post by:
Hi all, I'm having problems with datagrids and the currentcellchanged event. My problem is this: I have a datagrid on a form, if the user changes the text in a cell on the datagrid then tries to...
3
by: Mike Cooper | last post by:
I have been staring at the above error for over a week now! I have a an inherited data class looking like thus: Public Class DataGridBoolColumnInherit Inherits...
1
by: nate axtell | last post by:
In VB .Net I made a custom CheckBox column style (for the Datagrid control) that maps to two DataTable columns , one it uses for the Checked status and the other it uses for the Enabled status. I am...
4
by: tg | last post by:
Visual Studio 2003 My problem is that I am dynamically creating a datagrid on pageload. The datagrid is completely dynamic as it is based on the number of columns returned from a recordset. The...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.