如何设置ListView控件背景色,最好是间隔的,就像CSDN的各个贴子之间的间隔色一样!

blueheart9734 2003-08-21 04:44:29
如题,谢谢~~
...全文
61 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
射天狼 2003-08-21
  • 打赏
  • 举报
回复
Option Explicit

'添加一个PictureBox控件,名称为:picGreenbar
Private Sub Form_Load()
'Vars for greenbar code
Dim i As Integer
Dim iFontHeight As Long
Dim iBarHeight As Integer
Dim j As Integer
Dim itmX As ListItem
Dim ColHead As ColumnHeader
ListView1.ColumnHeaders.Add , , "This is Just a Simple Example"
ListView1.ColumnHeaders(1).Width = 3000


For j = 1 To 33
Set itmX = ListView1.ListItems.Add()
itmX.Text = "This is item number " & CStr(j)
Next j
Me.ScaleMode = vbTwips 'make sure our form is In twips
picGreenbar.ScaleMode = vbTwips
picGreenbar.BorderStyle = vbBSNone 'this is important - we don't want To measure the border In our calcs.
picGreenbar.AutoRedraw = True
picGreenbar.Visible = False
picGreenbar.Font = ListView1.Font
iFontHeight = picGreenbar.TextHeight("b") + Screen.TwipsPerPixelY
iBarHeight = (iFontHeight * 1) '3 line wide greenbars.
picGreenbar.Width = ListView1.Width
'======
picGreenbar.Height = iBarHeight * 2
picGreenbar.ScaleMode = vbUser
picGreenbar.ScaleHeight = 2 '2 bar-widths high
picGreenbar.ScaleWidth = 1 '1 bar-width wide
'draw the actual bars
picGreenbar.Line (0, 0)-(1, 1), vbWhite, BF 'white bars - modify vbWhite To change bar color
picGreenbar.Line (0, 1)-(1, 2), RGB(227, 241, 226), BF 'light green bars - modify RGB(x,x,x) To change bar color
'======
'put it in the listview control, tiled
ListView1.PictureAlignment = lvwTile
ListView1.Picture = picGreenbar.Image
End Sub
射天狼 2003-08-21
  • 打赏
  • 举报
回复
strongfisher 2003-08-21
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=7273

7,759

社区成员

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

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