用代码实现ListView控件的行间隔颜色
首先,在窗口中添加一个ListView控件。方法是:菜单->工程->零件-> Microsoft Window Common Control 6.0(后面是版本号)。添加另一个图片控件,并将其重命名为picGreenbar。
实现代码如下:
选项显式
private Sub Form _ Load()
Dim I As Integer
Dim iFontHeight As Long
Dim iBarHeight As Integer
Dim j As Integer
Dim itmX As ListItem
Dim ColHead As column header
listview 1 .ColumnHeaders.Add,“这只是一个简单的例子”
ListView1。ColumnHeaders(1)。宽度= 3000
'为j = 1到33
set itmx = listview 1 . listitems . Add()
itmx . text = " this is itemnumber " & CSTR(j)
下一个j
我。scale mode = VBTwips
picGreenbar。scale mode = VBTwips
picGreenbar。border style = VBBSNone
picGreenbar。autore draw = True
picGreenbar。Visible = False
picGreenbar。Font = ListView1。font
iFontHeight = picGreenbar。TextHeight("b") + Screen。TwipsPerPixelY
iBarHeight =(ifonheight * 1)
picGreenbar。宽度=列表视图1。width
' = = = = = = =
picGreenbar。height = iBarHeight * 2
picGreenbar。scale mode = VB user
picGreenbar。ScaleHeight = 2
picGreenbar。ScaleWidth = 1 [/ br/]'绘制实际的条形图
picGreenbar。Line (0,0)-(1,1),VBWhite,BF
picGreenbar。Line (0,1)-(1,2),RGB(227,241,226),BF
' = = = = = = =
listview 1。picture alignment = lvwTile
listview 1。图片= picGreenbar。Image
End Sub
0条评论