datagrid,关于改变所在行的颜色?

riconyi 2004-04-27 12:36:50
With grdColStyle5
.HeaderText = "材料名称"
.MappingName = "材料名称"
.NullText = ""
End With
上面这句将里面的null换成了空格,请问可不可以将其所在的行的背影颜色改变或字体加粗?
...全文
70 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
CMIC 2004-04-28
  • 打赏
  • 举报
回复
http://www.csdn.net/Develop/Read_Article.asp?Id=15928
taofirst 2004-04-28
  • 打赏
  • 举报
回复
' DataGridColoredTextBoxColumn 的功能:
' 改变datagrid中特定行的颜色(根据该行中某些字段的值)

Public Class DataGridColoredTextBoxColumn
Inherits DataGridTextBoxColumn

Private m_BackColor As Color = Color.White
Private m_ForeColor As Color = Color.Black

Public Event GetColors(ByVal rownum As Integer, ByRef bBack As Color, ByRef bFore As Color)

Property BackColor() As Color
Get
Return m_BackColor
End Get
Set(ByVal Value As Color)
m_BackColor = Value
End Set
End Property

Property ForeColor() As Color
Get
Return m_ForeColor
End Get
Set(ByVal Value As Color)
m_ForeColor = Value
End Set
End Property

Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal r As Rectangle, ByVal cm As CurrencyManager, ByVal rownum As Integer)
Dim b As Color = BackColor
Dim f As Color = ForeColor
RaiseEvent GetColors(rownum, b, f)
Call MyBase.Paint(g, r, cm, rownum, New SolidBrush(b), New SolidBrush(f), False)
End Sub

Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal r As Rectangle, ByVal cm As CurrencyManager, ByVal rownum As Integer, ByVal bAlignRight As Boolean)
Dim b As Color = BackColor
Dim f As Color = ForeColor
RaiseEvent GetColors(rownum, b, f)
Call MyBase.Paint(g, r, cm, rownum, New SolidBrush(b), New SolidBrush(f), bAlignRight)
End Sub

Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal r As Rectangle, ByVal cm As CurrencyManager, ByVal rownum As Integer, ByVal bBack As Brush, ByVal bFore As Brush, ByVal bAlignRight As Boolean)
Dim b As Color = BackColor
Dim f As Color = ForeColor
RaiseEvent GetColors(rownum, b, f)
Call MyBase.Paint(g, r, cm, rownum, New SolidBrush(b), New SolidBrush(f), bAlignRight)
End Sub

End Class
riconyi 2004-04-28
  • 打赏
  • 举报
回复
我顶
wangjian 2004-04-28
  • 打赏
  • 举报
回复
可以,但要重写列样式的绘制事件
感兴趣可以去WWW.SHSOFTS.COM看看
企业通用软件 2004-04-27
  • 打赏
  • 举报
回复
UP

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧