Hey all,
You notice how when you mouse over each thread in this forum how the
highlights, well how can I do this same thing in my win form with my datagrid?
thanks,
rodchar 10 1175
Hi,
You need to make your own columnstyle for that. Here is a column i
am working on that does that.
Code
Imports System.Drawing
Imports System.Drawing. Drawing2D
Imports System.Windows. Forms
Imports System.Reflecti on
Imports System.Componen tModel
Public Class HotTrackTextBox Column
Inherits DataGridTextBox Column
Dim c As Integer
Dim rectPaint As New RectangleF
Dim fnt As New Font(MyBase.Tex tBox.Font.Name, MyBase.TextBox. Font.Size,
FontStyle.Under line)
Dim WithEvents dg As DataGrid
Dim oldCell As New Point(-1, -1)
Dim isInCell As Boolean = False
Public Sub HandleMouseMove (ByVal sender As Object, ByVal e As
MouseEventArgs) Handles dg.MouseMove
Dim g As Graphics = dg.CreateGraphi cs
Dim bounds As Rectangle
Dim hti As DataGrid.HitTes tInfo = dg.HitTest(New Point(e.X, e.Y))
isInCell = (hti.Row > -1 And hti.Column = c)
Static bRedraw As Boolean = False
If isInCell Then
Dim pt As Point
pt = New Point(hti.Row, hti.Column)
If Not pt.Equals(oldCe ll) Then
'
' Create a region where we want the datagrid to redraw
' So the datagrid doesn't flash.
'
Dim pthToRedraw As New Drawing2D.Graph icsPath
Dim rgnToRedraw As Region
Dim rCell As Rectangle = dg.GetCellBound s(pt.X, pt.Y)
pthToRedraw.Add Rectangle(rCell )
If oldCell.X > -1 Then
'
' Have to redraw last cell
'
pthToRedraw.Add Rectangle(dg.Ge tCellBounds(old Cell.X, oldCell.Y))
End If
rgnToRedraw = New Region(pthToRed raw)
dg.Invalidate(r gnToRedraw)
End If
'
' Flag datagrid for redraw
'
bRedraw = True
oldCell = pt
Else
'
' Only redraw when needed
'
If bRedraw Then
dg.Invalidate(d g.GetCellBounds (oldCell.X, oldCell.Y))
End If
bRedraw = False
oldCell = New Point(-1, -1)
End If
End Sub
Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing. Graphics,
ByVal bounds As System.Drawing. Rectangle, ByVal source As
System.Windows. Forms.CurrencyM anager, ByVal rowNum As Integer, ByVal
backBrush As System.Drawing. Brush, ByVal foreBrush As System.Drawing. Brush,
ByVal alignToRight As Boolean)
Static bPainted As Boolean = False
'
' First time we paint get a reference to datagrid
' So we can consume its events
'
If Not bPainted Then
dg = Me.DataGridTabl eStyle.DataGrid
c = -1
For Each grdCol As DataGridColumnS tyle In
Me.DataGridTabl eStyle.GridColu mnStyles
c += 1
If grdCol.MappingN ame = Me.MappingName Then Exit For
Next
End If
bPainted = True
MyBase.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight)
Dim pnHot As New Pen(SystemColor s.HotTrack)
Dim brHot As New SolidBrush(Colo r.FromArgb(128, SystemColors.Ho tTrack))
' see through brush
If MouseOverCell(r owNum) Then
bounds.Inflate(-1, -1)
g.FillRectangle (brHot, bounds)
g.DrawRectangle (pnHot, bounds)
End If
Dim r As New RectangleF(boun ds.X, bounds.Y, bounds.Width, bounds.Height)
rectPaint = r
End Sub
Public ReadOnly Property MouseOverCell(B yVal rownum As Integer) As Boolean
Get
Dim pt As New Point(rownum, c)
Return pt.Equals(oldCe ll)
End Get
End Property
End Class
Link to example http://www.onteorasoftware.com/Downl...lumnstyles.zip
Ken
-----------------------
"rodchar" <ro*****@discus sions.microsoft .com> wrote in message
news:46******** *************** ***********@mic rosoft.com...
Hey all,
You notice how when you mouse over each thread in this forum how the
highlights, well how can I do this same thing in my win form with my
datagrid?
thanks,
rodchar
I appreciate it.
"Ken Tucker [MVP]" wrote: Hi,
You need to make your own columnstyle for that. Here is a column i am working on that does that.
Code
Imports System.Drawing
Imports System.Drawing. Drawing2D
Imports System.Windows. Forms
Imports System.Reflecti on
Imports System.Componen tModel
Public Class HotTrackTextBox Column
Inherits DataGridTextBox Column
Dim c As Integer
Dim rectPaint As New RectangleF
Dim fnt As New Font(MyBase.Tex tBox.Font.Name, MyBase.TextBox. Font.Size, FontStyle.Under line)
Dim WithEvents dg As DataGrid
Dim oldCell As New Point(-1, -1)
Dim isInCell As Boolean = False
Public Sub HandleMouseMove (ByVal sender As Object, ByVal e As MouseEventArgs) Handles dg.MouseMove
Dim g As Graphics = dg.CreateGraphi cs
Dim bounds As Rectangle
Dim hti As DataGrid.HitTes tInfo = dg.HitTest(New Point(e.X, e.Y))
isInCell = (hti.Row > -1 And hti.Column = c)
Static bRedraw As Boolean = False
If isInCell Then
Dim pt As Point
pt = New Point(hti.Row, hti.Column)
If Not pt.Equals(oldCe ll) Then
'
' Create a region where we want the datagrid to redraw
' So the datagrid doesn't flash.
'
Dim pthToRedraw As New Drawing2D.Graph icsPath
Dim rgnToRedraw As Region
Dim rCell As Rectangle = dg.GetCellBound s(pt.X, pt.Y)
pthToRedraw.Add Rectangle(rCell )
If oldCell.X > -1 Then
'
' Have to redraw last cell
'
pthToRedraw.Add Rectangle(dg.Ge tCellBounds(old Cell.X, oldCell.Y))
End If
rgnToRedraw = New Region(pthToRed raw)
dg.Invalidate(r gnToRedraw)
End If
'
' Flag datagrid for redraw
'
bRedraw = True
oldCell = pt
Else
'
' Only redraw when needed
'
If bRedraw Then
dg.Invalidate(d g.GetCellBounds (oldCell.X, oldCell.Y))
End If
bRedraw = False
oldCell = New Point(-1, -1)
End If
End Sub Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing. Graphics, ByVal bounds As System.Drawing. Rectangle, ByVal source As System.Windows. Forms.CurrencyM anager, ByVal rowNum As Integer, ByVal backBrush As System.Drawing. Brush, ByVal foreBrush As System.Drawing. Brush, ByVal alignToRight As Boolean)
Static bPainted As Boolean = False
'
' First time we paint get a reference to datagrid
' So we can consume its events
'
If Not bPainted Then
dg = Me.DataGridTabl eStyle.DataGrid
c = -1
For Each grdCol As DataGridColumnS tyle In Me.DataGridTabl eStyle.GridColu mnStyles
c += 1
If grdCol.MappingN ame = Me.MappingName Then Exit For
Next
End If
bPainted = True
MyBase.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight)
Dim pnHot As New Pen(SystemColor s.HotTrack)
Dim brHot As New SolidBrush(Colo r.FromArgb(128, SystemColors.Ho tTrack))
' see through brush
If MouseOverCell(r owNum) Then
bounds.Inflate(-1, -1)
g.FillRectangle (brHot, bounds)
g.DrawRectangle (pnHot, bounds)
End If Dim r As New RectangleF(boun ds.X, bounds.Y, bounds.Width, bounds.Height)
rectPaint = r
End Sub
Public ReadOnly Property MouseOverCell(B yVal rownum As Integer) As Boolean
Get
Dim pt As New Point(rownum, c)
Return pt.Equals(oldCe ll)
End Get
End Property
End Class
Link to example http://www.onteorasoftware.com/Downl...lumnstyles.zip
Ken ----------------------- "rodchar" <ro*****@discus sions.microsoft .com> wrote in message news:46******** *************** ***********@mic rosoft.com... Hey all,
You notice how when you mouse over each thread in this forum how the highlights, well how can I do this same thing in my win form with my datagrid?
thanks, rodchar
all the code goes behind my Form1 code behind?
"Ken Tucker [MVP]" wrote: Hi,
You need to make your own columnstyle for that. Here is a column i am working on that does that.
Code
Imports System.Drawing
Imports System.Drawing. Drawing2D
Imports System.Windows. Forms
Imports System.Reflecti on
Imports System.Componen tModel
Public Class HotTrackTextBox Column
Inherits DataGridTextBox Column
Dim c As Integer
Dim rectPaint As New RectangleF
Dim fnt As New Font(MyBase.Tex tBox.Font.Name, MyBase.TextBox. Font.Size, FontStyle.Under line)
Dim WithEvents dg As DataGrid
Dim oldCell As New Point(-1, -1)
Dim isInCell As Boolean = False
Public Sub HandleMouseMove (ByVal sender As Object, ByVal e As MouseEventArgs) Handles dg.MouseMove
Dim g As Graphics = dg.CreateGraphi cs
Dim bounds As Rectangle
Dim hti As DataGrid.HitTes tInfo = dg.HitTest(New Point(e.X, e.Y))
isInCell = (hti.Row > -1 And hti.Column = c)
Static bRedraw As Boolean = False
If isInCell Then
Dim pt As Point
pt = New Point(hti.Row, hti.Column)
If Not pt.Equals(oldCe ll) Then
'
' Create a region where we want the datagrid to redraw
' So the datagrid doesn't flash.
'
Dim pthToRedraw As New Drawing2D.Graph icsPath
Dim rgnToRedraw As Region
Dim rCell As Rectangle = dg.GetCellBound s(pt.X, pt.Y)
pthToRedraw.Add Rectangle(rCell )
If oldCell.X > -1 Then
'
' Have to redraw last cell
'
pthToRedraw.Add Rectangle(dg.Ge tCellBounds(old Cell.X, oldCell.Y))
End If
rgnToRedraw = New Region(pthToRed raw)
dg.Invalidate(r gnToRedraw)
End If
'
' Flag datagrid for redraw
'
bRedraw = True
oldCell = pt
Else
'
' Only redraw when needed
'
If bRedraw Then
dg.Invalidate(d g.GetCellBounds (oldCell.X, oldCell.Y))
End If
bRedraw = False
oldCell = New Point(-1, -1)
End If
End Sub Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing. Graphics, ByVal bounds As System.Drawing. Rectangle, ByVal source As System.Windows. Forms.CurrencyM anager, ByVal rowNum As Integer, ByVal backBrush As System.Drawing. Brush, ByVal foreBrush As System.Drawing. Brush, ByVal alignToRight As Boolean)
Static bPainted As Boolean = False
'
' First time we paint get a reference to datagrid
' So we can consume its events
'
If Not bPainted Then
dg = Me.DataGridTabl eStyle.DataGrid
c = -1
For Each grdCol As DataGridColumnS tyle In Me.DataGridTabl eStyle.GridColu mnStyles
c += 1
If grdCol.MappingN ame = Me.MappingName Then Exit For
Next
End If
bPainted = True
MyBase.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight)
Dim pnHot As New Pen(SystemColor s.HotTrack)
Dim brHot As New SolidBrush(Colo r.FromArgb(128, SystemColors.Ho tTrack))
' see through brush
If MouseOverCell(r owNum) Then
bounds.Inflate(-1, -1)
g.FillRectangle (brHot, bounds)
g.DrawRectangle (pnHot, bounds)
End If Dim r As New RectangleF(boun ds.X, bounds.Y, bounds.Width, bounds.Height)
rectPaint = r
End Sub
Public ReadOnly Property MouseOverCell(B yVal rownum As Integer) As Boolean
Get
Dim pt As New Point(rownum, c)
Return pt.Equals(oldCe ll)
End Get
End Property
End Class
Link to example http://www.onteorasoftware.com/Downl...lumnstyles.zip
Ken ----------------------- "rodchar" <ro*****@discus sions.microsoft .com> wrote in message news:46******** *************** ***********@mic rosoft.com... Hey all,
You notice how when you mouse over each thread in this forum how the highlights, well how can I do this same thing in my win form with my datagrid?
thanks, rodchar
Rodchar,
I am still not sure if you are making programs for the web of for windows
forms, what is it, and when it is webform, I advice you to tell that in your
questions, I think I remember it when you answer it now. However in this
newsgroup is the winform default when not told.
Cor
Hi,
Sorry assumed this was for a windows form grid
Ken
-------------------------
"rodchar" <ro*****@discus sions.microsoft .com> wrote in message
news:B2******** *************** ***********@mic rosoft.com...
all the code goes behind my Form1 code behind?
"Ken Tucker [MVP]" wrote: Hi,
You need to make your own columnstyle for that. Here is a column i am working on that does that.
Code
Imports System.Drawing
Imports System.Drawing. Drawing2D
Imports System.Windows. Forms
Imports System.Reflecti on
Imports System.Componen tModel
Public Class HotTrackTextBox Column
Inherits DataGridTextBox Column
Dim c As Integer
Dim rectPaint As New RectangleF
Dim fnt As New Font(MyBase.Tex tBox.Font.Name, MyBase.TextBox. Font.Size, FontStyle.Under line)
Dim WithEvents dg As DataGrid
Dim oldCell As New Point(-1, -1)
Dim isInCell As Boolean = False
Public Sub HandleMouseMove (ByVal sender As Object, ByVal e As MouseEventArgs) Handles dg.MouseMove
Dim g As Graphics = dg.CreateGraphi cs
Dim bounds As Rectangle
Dim hti As DataGrid.HitTes tInfo = dg.HitTest(New Point(e.X, e.Y))
isInCell = (hti.Row > -1 And hti.Column = c)
Static bRedraw As Boolean = False
If isInCell Then
Dim pt As Point
pt = New Point(hti.Row, hti.Column)
If Not pt.Equals(oldCe ll) Then
'
' Create a region where we want the datagrid to redraw
' So the datagrid doesn't flash.
'
Dim pthToRedraw As New Drawing2D.Graph icsPath
Dim rgnToRedraw As Region
Dim rCell As Rectangle = dg.GetCellBound s(pt.X, pt.Y)
pthToRedraw.Add Rectangle(rCell )
If oldCell.X > -1 Then
'
' Have to redraw last cell
'
pthToRedraw.Add Rectangle(dg.Ge tCellBounds(old Cell.X, oldCell.Y))
End If
rgnToRedraw = New Region(pthToRed raw)
dg.Invalidate(r gnToRedraw)
End If
'
' Flag datagrid for redraw
'
bRedraw = True
oldCell = pt
Else
'
' Only redraw when needed
'
If bRedraw Then
dg.Invalidate(d g.GetCellBounds (oldCell.X, oldCell.Y))
End If
bRedraw = False
oldCell = New Point(-1, -1)
End If
End Sub Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing. Graphics, ByVal bounds As System.Drawing. Rectangle, ByVal source As System.Windows. Forms.CurrencyM anager, ByVal rowNum As Integer, ByVal backBrush As System.Drawing. Brush, ByVal foreBrush As System.Drawing. Brush, ByVal alignToRight As Boolean)
Static bPainted As Boolean = False
'
' First time we paint get a reference to datagrid
' So we can consume its events
'
If Not bPainted Then
dg = Me.DataGridTabl eStyle.DataGrid
c = -1
For Each grdCol As DataGridColumnS tyle In Me.DataGridTabl eStyle.GridColu mnStyles
c += 1
If grdCol.MappingN ame = Me.MappingName Then Exit For
Next
End If
bPainted = True
MyBase.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight)
Dim pnHot As New Pen(SystemColor s.HotTrack)
Dim brHot As New SolidBrush(Colo r.FromArgb(128, SystemColors.Ho tTrack))
' see through brush
If MouseOverCell(r owNum) Then
bounds.Inflate(-1, -1)
g.FillRectangle (brHot, bounds)
g.DrawRectangle (pnHot, bounds)
End If Dim r As New RectangleF(boun ds.X, bounds.Y, bounds.Width, bounds.Height)
rectPaint = r
End Sub
Public ReadOnly Property MouseOverCell(B yVal rownum As Integer) As Boolean
Get
Dim pt As New Point(rownum, c)
Return pt.Equals(oldCe ll)
End Get
End Property
End Class
Link to example http://www.onteorasoftware.com/Downl...lumnstyles.zip
Ken ----------------------- "rodchar" <ro*****@discus sions.microsoft .com> wrote in message news:46******** *************** ***********@mic rosoft.com... Hey all,
You notice how when you mouse over each thread in this forum how the highlights, well how can I do this same thing in my win form with my datagrid?
thanks, rodchar
yes, this is a windows forms project.
"Cor Ligthert" wrote: Rodchar,
I am still not sure if you are making programs for the web of for windows forms, what is it, and when it is webform, I advice you to tell that in your questions, I think I remember it when you answer it now. However in this newsgroup is the winform default when not told.
Cor
Rodchar,
Than you would not talk about :
ispostback
codebehind
That is typical webform terminology
In a windowform you have a design form and normalcode.
Ispostback does not exist.
You can real good confuse us.
:-)))
Cor
"rodchar" <ro*****@discus sions.microsoft .com> yes, this is a windows forms project.
"Cor Ligthert" wrote:
Rodchar,
I am still not sure if you are making programs for the web of for windows forms, what is it, and when it is webform, I advice you to tell that in your questions, I think I remember it when you answer it now. However in this newsgroup is the winform default when not told.
Cor
You're right it is a win form project. So am i correct to say put it in the
code behind of the form or in a class by itself?
"Ken Tucker [MVP]" wrote: Hi,
Sorry assumed this was for a windows form grid
Ken ------------------------- "rodchar" <ro*****@discus sions.microsoft .com> wrote in message news:B2******** *************** ***********@mic rosoft.com... all the code goes behind my Form1 code behind?
"Ken Tucker [MVP]" wrote:
Hi,
You need to make your own columnstyle for that. Here is a column i am working on that does that.
Code
Imports System.Drawing
Imports System.Drawing. Drawing2D
Imports System.Windows. Forms
Imports System.Reflecti on
Imports System.Componen tModel
Public Class HotTrackTextBox Column
Inherits DataGridTextBox Column
Dim c As Integer
Dim rectPaint As New RectangleF
Dim fnt As New Font(MyBase.Tex tBox.Font.Name, MyBase.TextBox. Font.Size, FontStyle.Under line)
Dim WithEvents dg As DataGrid
Dim oldCell As New Point(-1, -1)
Dim isInCell As Boolean = False
Public Sub HandleMouseMove (ByVal sender As Object, ByVal e As MouseEventArgs) Handles dg.MouseMove
Dim g As Graphics = dg.CreateGraphi cs
Dim bounds As Rectangle
Dim hti As DataGrid.HitTes tInfo = dg.HitTest(New Point(e.X, e.Y))
isInCell = (hti.Row > -1 And hti.Column = c)
Static bRedraw As Boolean = False
If isInCell Then
Dim pt As Point
pt = New Point(hti.Row, hti.Column)
If Not pt.Equals(oldCe ll) Then
'
' Create a region where we want the datagrid to redraw
' So the datagrid doesn't flash.
'
Dim pthToRedraw As New Drawing2D.Graph icsPath
Dim rgnToRedraw As Region
Dim rCell As Rectangle = dg.GetCellBound s(pt.X, pt.Y)
pthToRedraw.Add Rectangle(rCell )
If oldCell.X > -1 Then
'
' Have to redraw last cell
'
pthToRedraw.Add Rectangle(dg.Ge tCellBounds(old Cell.X, oldCell.Y))
End If
rgnToRedraw = New Region(pthToRed raw)
dg.Invalidate(r gnToRedraw)
End If
'
' Flag datagrid for redraw
'
bRedraw = True
oldCell = pt
Else
'
' Only redraw when needed
'
If bRedraw Then
dg.Invalidate(d g.GetCellBounds (oldCell.X, oldCell.Y))
End If
bRedraw = False
oldCell = New Point(-1, -1)
End If
End Sub Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing. Graphics, ByVal bounds As System.Drawing. Rectangle, ByVal source As System.Windows. Forms.CurrencyM anager, ByVal rowNum As Integer, ByVal backBrush As System.Drawing. Brush, ByVal foreBrush As System.Drawing. Brush, ByVal alignToRight As Boolean)
Static bPainted As Boolean = False
'
' First time we paint get a reference to datagrid
' So we can consume its events
'
If Not bPainted Then
dg = Me.DataGridTabl eStyle.DataGrid
c = -1
For Each grdCol As DataGridColumnS tyle In Me.DataGridTabl eStyle.GridColu mnStyles
c += 1
If grdCol.MappingN ame = Me.MappingName Then Exit For
Next
End If
bPainted = True
MyBase.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight)
Dim pnHot As New Pen(SystemColor s.HotTrack)
Dim brHot As New SolidBrush(Colo r.FromArgb(128, SystemColors.Ho tTrack))
' see through brush
If MouseOverCell(r owNum) Then
bounds.Inflate(-1, -1)
g.FillRectangle (brHot, bounds)
g.DrawRectangle (pnHot, bounds)
End If Dim r As New RectangleF(boun ds.X, bounds.Y, bounds.Width, bounds.Height)
rectPaint = r
End Sub
Public ReadOnly Property MouseOverCell(B yVal rownum As Integer) As Boolean
Get
Dim pt As New Point(rownum, c)
Return pt.Equals(oldCe ll)
End Get
End Property
End Class
Link to example http://www.onteorasoftware.com/Downl...lumnstyles.zip
Ken ----------------------- "rodchar" <ro*****@discus sions.microsoft .com> wrote in message news:46******** *************** ***********@mic rosoft.com... Hey all,
You notice how when you mouse over each thread in this forum how the highlights, well how can I do this same thing in my win form with my datagrid?
thanks, rodchar
Hi,
Class by itself. You did see the link to the example at the end.
Ken
-----------------------
"rodchar" <ro*****@discus sions.microsoft .com> wrote in message
news:D6******** *************** ***********@mic rosoft.com...
You're right it is a win form project. So am i correct to say put it in the
code behind of the form or in a class by itself?
"Ken Tucker [MVP]" wrote: Hi,
Sorry assumed this was for a windows form grid
Ken ------------------------- "rodchar" <ro*****@discus sions.microsoft .com> wrote in message news:B2******** *************** ***********@mic rosoft.com... all the code goes behind my Form1 code behind?
"Ken Tucker [MVP]" wrote:
Hi,
You need to make your own columnstyle for that. Here is a column i am working on that does that.
Code
Imports System.Drawing
Imports System.Drawing. Drawing2D
Imports System.Windows. Forms
Imports System.Reflecti on
Imports System.Componen tModel
Public Class HotTrackTextBox Column
Inherits DataGridTextBox Column
Dim c As Integer
Dim rectPaint As New RectangleF
Dim fnt As New Font(MyBase.Tex tBox.Font.Name, MyBase.TextBox. Font.Size, FontStyle.Under line)
Dim WithEvents dg As DataGrid
Dim oldCell As New Point(-1, -1)
Dim isInCell As Boolean = False
Public Sub HandleMouseMove (ByVal sender As Object, ByVal e As MouseEventArgs) Handles dg.MouseMove
Dim g As Graphics = dg.CreateGraphi cs
Dim bounds As Rectangle
Dim hti As DataGrid.HitTes tInfo = dg.HitTest(New Point(e.X, e.Y))
isInCell = (hti.Row > -1 And hti.Column = c)
Static bRedraw As Boolean = False
If isInCell Then
Dim pt As Point
pt = New Point(hti.Row, hti.Column)
If Not pt.Equals(oldCe ll) Then
'
' Create a region where we want the datagrid to redraw
' So the datagrid doesn't flash.
'
Dim pthToRedraw As New Drawing2D.Graph icsPath
Dim rgnToRedraw As Region
Dim rCell As Rectangle = dg.GetCellBound s(pt.X, pt.Y)
pthToRedraw.Add Rectangle(rCell )
If oldCell.X > -1 Then
'
' Have to redraw last cell
'
pthToRedraw.Add Rectangle(dg.Ge tCellBounds(old Cell.X, oldCell.Y))
End If
rgnToRedraw = New Region(pthToRed raw)
dg.Invalidate(r gnToRedraw)
End If
'
' Flag datagrid for redraw
'
bRedraw = True
oldCell = pt
Else
'
' Only redraw when needed
'
If bRedraw Then
dg.Invalidate(d g.GetCellBounds (oldCell.X, oldCell.Y))
End If
bRedraw = False
oldCell = New Point(-1, -1)
End If
End Sub Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing. Graphics, ByVal bounds As System.Drawing. Rectangle, ByVal source As System.Windows. Forms.CurrencyM anager, ByVal rowNum As Integer, ByVal backBrush As System.Drawing. Brush, ByVal foreBrush As System.Drawing. Brush, ByVal alignToRight As Boolean)
Static bPainted As Boolean = False
'
' First time we paint get a reference to datagrid
' So we can consume its events
'
If Not bPainted Then
dg = Me.DataGridTabl eStyle.DataGrid
c = -1
For Each grdCol As DataGridColumnS tyle In Me.DataGridTabl eStyle.GridColu mnStyles
c += 1
If grdCol.MappingN ame = Me.MappingName Then Exit For
Next
End If
bPainted = True
MyBase.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight)
Dim pnHot As New Pen(SystemColor s.HotTrack)
Dim brHot As New SolidBrush(Colo r.FromArgb(128, SystemColors.Ho tTrack))
' see through brush
If MouseOverCell(r owNum) Then
bounds.Inflate(-1, -1)
g.FillRectangle (brHot, bounds)
g.DrawRectangle (pnHot, bounds)
End If Dim r As New RectangleF(boun ds.X, bounds.Y, bounds.Width, bounds.Height)
rectPaint = r
End Sub
Public ReadOnly Property MouseOverCell(B yVal rownum As Integer) As Boolean
Get
Dim pt As New Point(rownum, c)
Return pt.Equals(oldCe ll)
End Get
End Property
End Class
Link to example http://www.onteorasoftware.com/Downl...lumnstyles.zip
Ken ----------------------- "rodchar" <ro*****@discus sions.microsoft .com> wrote in message news:46******** *************** ***********@mic rosoft.com... Hey all,
You notice how when you mouse over each thread in this forum how the highlights, well how can I do this same thing in my win form with my datagrid?
thanks, rodchar This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: greg.knaddison |
last post by:
Hi,
I'm trying to use the httpclient within Jython (see
http://jakarta.apache.org/commons/httpclient/ for more information on
the httpclient).
My Jython version is:
Jython 2.1 on java1.4.2_04 (JIT: null)
My Java version is:
|
by: Mtcc |
last post by:
it seem like microsoft support in .NET control for ME lenguage to write
Right-to-left (RTL)
but until now i not success to get textbox that get in Run time RTL kyboard?
i set Lang in Form to ME lang, and i set all RTL property to yes??
|
by: news.microsoft.com |
last post by:
To Microsoft and fellow MSDN Universal subscribers...
Regarding new MSDN Universal (I mean Premier) price and level changes:
1) Way too expensive for the small and medium developer Universal subscriber
(and some large ones as well). $10,000 - $15,000 per user?!? Forget it!
2) Do you (MS) honestly believe that the market you are targeting will just
buy this product on good faith? Without our recommendations? Think about
|
by: Stamen Gortchev |
last post by:
Hi all,
I think there is an inherent problem with most examples on the internet
(with MSDN, too!) showing datagrid's databinding. Here is, how they look
like:
========================
On Page_Load
if !IsPostBack: BindGrid()
|
by: daniel |
last post by:
Hi guys
Has Anyone a msdn theme??, I want use him in my aspnet 2.0 project.
thanks in advance
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |