DataGridView重绘问题

鏡椛氹鈅 2014-11-26 10:18:55


如何重绘DataGridView实现上述效果,望高人指点下...

...全文
395 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
鏡椛氹鈅 2014-11-26
  • 打赏
  • 举报
回复
引用 1 楼 bdmh 的回复:
cellpaiting或grid的onpaint
昨天试了一晚上oncellpaiting和onpaint 画不出来,今天在尝试OnRowPostPaint 版主能否给点代码借鉴下...
bdmh 2014-11-26
  • 打赏
  • 举报
回复
cellpaiting或grid的onpaint
鏡椛氹鈅 2014-11-26
  • 打赏
  • 举报
回复
Protected Overrides Sub OnCellPainting(ByVal e As DataGridViewCellPaintingEventArgs) MyBase.OnCellPainting(e) AlternatingRowsDefaultCellStyle.BackColor = Color.AliceBlue Dim r As Rectangle = e.CellBounds Dim p As Pen = New Pen(Color.SkyBlue, 2) r.Offset(New Point(0, 0)) If (e.RowIndex = -1) Then e.CellStyle.BackColor = Color.AliceBlue e.CellStyle.Font = New Drawing.Font(e.CellStyle.Font, FontStyle.Bold) End If Using b As Drawing2D.LinearGradientBrush = New Drawing2D.LinearGradientBrush(e.CellBounds, e.CellStyle.BackColor, e.CellStyle.BackColor, 1, True) e.Graphics.FillRectangle(b, e.CellBounds) End Using e.CellStyle.SelectionBackColor = Color.Color.Red e.CellStyle.SelectionForeColor = Color.FromArgb(10, 50, 205, 50) e.Graphics.DrawRectangle(p, r) e.Graphics.DrawRectangle(p, r) e.PaintContent(e.ClipBounds) e.Handled = True End Sub 重绘代码,麻烦高手看下为什么e.CellStyle.SelectionBackColor = Color.Red没有效果
鏡椛氹鈅 2014-11-26
  • 打赏
  • 举报
回复
引用 3 楼 effun 的回复:
直接设置单元格的背景色不行吗?
跟单元格颜色有关系吗?
鏡椛氹鈅 2014-11-26
  • 打赏
  • 举报
回复
在oncellpaiting将单元格背景色和边框线绘制好了,为什么选中行的背景色设置无效,前景色却有效,求大神解释下...
caoqijun 2014-11-26
  • 打赏
  • 举报
回复
onpaint
effun 2014-11-26
  • 打赏
  • 举报
回复
直接设置单元格的背景色不行吗?

16,550

社区成员

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

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