画listview背景的问题

cnwangbo 2007-12-10 10:22:37

'*********************************************************************
' SetListItemColor方法有三个参数,ListView控件的名称,字符串,PictureBox控件的名称
’VB里,当listview.listItem>1000时,怎么画Listitem的背景,并且显示没问题。
'*********************************************************************
Private Sub SetListItemColor(lv As ListView, strOffset As String, picBg As PictureBox)

On Error GoTo ErrorHandling
Dim i As Integer
Dim j As Integer
Dim mItem As ListItem
Dim strOff() As String
Dim flag As Boolean

picBg.BackColor = lv.BackColor
lv.Parent.ScaleMode = vbTwips
picBg.ScaleMode = vbTwips
picBg.BorderStyle = vbBSNone
picBg.AutoRedraw = True
picBg.Visible = False
picBg.Width = lv.Width
picBg.Height = lv.ListItems(1).Height * (lv.ListItems.Count)
picBg.ScaleHeight = lv.ListItems.Count
picBg.ScaleWidth = 1
picBg.DrawWidth = 1
strOff = split(strOffset, ",")
Dim itemp As Integer
For i = 1 To lv.ListItems.Count
For j = 0 To UBound(strOff)
If lv.ListItems.Item(i).SubItems(5) = strOff(j) Then
picBg.Line (0, i - 1)-(1, i), RGB(255, 100, 50), BF
End If
Next
Next
lv.Picture = picBg.Image
ErrorHandling:

End Sub

问题特征:当lv.ListItems.Count<500时,lv.ListItems的背景色显示正常,当lv.ListItems.Count>500或更大时,lv.ListItems的背景色显示不正常。
求助:那位大哥能帮小弟解决此问题,愿献上5分。或更多。谢谢。附件里是,结果显示的界面。
...全文
105 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnwangbo 2007-12-18
  • 打赏
  • 举报
回复
单纯的想用画图的方式,是达不到完美的效果的。
可以用设置字体的颜色来实现。

lv.ListItems.Item(k).ListSubItems(t).ForeColor = vbRed
lv.ListItems.Item(k).ListSubItems(t).Bold = True

cnwangbo 2007-12-10
  • 打赏
  • 举报
回复
每次刷新的時候是重繪的。
cangwu_lee 2007-12-10
  • 打赏
  • 举报
回复
要每次刷新的時候重繪

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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