S
Sam
I inherited the DataGridTextBoxColumn, so I could have some columns be
different colors. The Inherited class is this:
*********************************************************
Public Class DGTextBoxColumn
Inherits DataGridTextBoxColumn
Private m_objBackColor As Color
Private m_objForeColor As Color
'Private m_objRealValue As New Object
'Private m_strPounds As String
Public Sub New(ByVal BackColor As Color, ByVal ForeColor As Color)
MyBase.New()
m_objBackColor = BackColor
m_objForeColor = ForeColor
End Sub
Public Sub New()
MyBase.New()
End Sub
'-----------------------------------------------------------
'PURPOSE: Override the Paint method in order to use back and
' fore colors if set, by passing new brushes to the
' the mybase paint method.
'-----------------------------------------------------------
Protected Overloads Overrides Sub Paint( _
ByVal g As System.Drawing.Graphics, _
ByVal bounds As System.Drawing.Rectangle, _
ByVal source As System.Windows.Forms.CurrencyManager, _
ByVal rowNum As Integer, _
ByVal backBrush As System.Drawing.Brush, _
ByVal foreBrush As System.Drawing.Brush, _
ByVal alignToRight As Boolean)
'If the back/fore colors have been set, then use those
'to paint the textbox, otherwise, use the default colors.
If (m_objBackColor.ToArgb = 0) Then
MyBase.Paint(g, bounds, source, rowNum, backBrush, _
foreBrush, alignToRight)
Else
MyBase.Paint(g, bounds, source, rowNum, _
New SolidBrush(m_objBackColor), _
New SolidBrush(m_objForeColor), alignToRight)
End If
End Sub
End Class
*********************************************************
The problem is, when I select a row, some of the columns get
highlighted and some don't. The ones that get highlighted are the
columns that uses the New with no parameters (default colors and
default backBrush and foreBrush in MyBase.Paint method). The ones
that don't get highlighted are the ones that use the New where colors
are passed.
I've tried setting the TableStyle SelectionBackColor and
SelectionForeColor to something, and that color is then used, but the
columns with specific colors are still not highlighted when the row is
selected. Anyone have any ideas on how to get the columns with
specified back/fore colors to highlight too?
Thanks...
different colors. The Inherited class is this:
*********************************************************
Public Class DGTextBoxColumn
Inherits DataGridTextBoxColumn
Private m_objBackColor As Color
Private m_objForeColor As Color
'Private m_objRealValue As New Object
'Private m_strPounds As String
Public Sub New(ByVal BackColor As Color, ByVal ForeColor As Color)
MyBase.New()
m_objBackColor = BackColor
m_objForeColor = ForeColor
End Sub
Public Sub New()
MyBase.New()
End Sub
'-----------------------------------------------------------
'PURPOSE: Override the Paint method in order to use back and
' fore colors if set, by passing new brushes to the
' the mybase paint method.
'-----------------------------------------------------------
Protected Overloads Overrides Sub Paint( _
ByVal g As System.Drawing.Graphics, _
ByVal bounds As System.Drawing.Rectangle, _
ByVal source As System.Windows.Forms.CurrencyManager, _
ByVal rowNum As Integer, _
ByVal backBrush As System.Drawing.Brush, _
ByVal foreBrush As System.Drawing.Brush, _
ByVal alignToRight As Boolean)
'If the back/fore colors have been set, then use those
'to paint the textbox, otherwise, use the default colors.
If (m_objBackColor.ToArgb = 0) Then
MyBase.Paint(g, bounds, source, rowNum, backBrush, _
foreBrush, alignToRight)
Else
MyBase.Paint(g, bounds, source, rowNum, _
New SolidBrush(m_objBackColor), _
New SolidBrush(m_objForeColor), alignToRight)
End If
End Sub
End Class
*********************************************************
The problem is, when I select a row, some of the columns get
highlighted and some don't. The ones that get highlighted are the
columns that uses the New with no parameters (default colors and
default backBrush and foreBrush in MyBase.Paint method). The ones
that don't get highlighted are the ones that use the New where colors
are passed.
I've tried setting the TableStyle SelectionBackColor and
SelectionForeColor to something, and that color is then used, but the
columns with specific colors are still not highlighted when the row is
selected. Anyone have any ideas on how to get the columns with
specified back/fore colors to highlight too?
Thanks...