listbox用类实现两种颜色交替显示每行?如题 谢谢了
答案:2 悬赏:30 手机版
解决时间 2021-11-11 19:42
- 提问者网友:且恨且铭记
- 2021-11-11 14:11
listbox用类实现两种颜色交替显示每行?如题 谢谢了
最佳答案
- 五星知识达人网友:人间朝暮
- 2021-11-11 14:16
添加一个listbox 名字改成listbox1 添加一个picturebox 名字改成picGreenbar Option Explicit Private Sub Form_Load() Dim j As Integer Dim itmX As ListItem ListView1.ColumnHeaders.Add , , "This is Just a Simple Example" ListView1.ColumnHeaders(1).Width = 3000 ListView1.View = lvwReport ListView1.FullRowSelect = True ListView1.GridLines = True picGreenbar.Height = 1 '添加一些实验数据 For j = 1 To 33 Set itmX = ListView1.ListItems.Add() itmX.Text = "This is item number " & CStr(j) Next j Call ColorListView(Me.ListView1, Me.picGreenbar) End Sub Private Sub Form_Resize() ListView1.Width = Me.ScaleWidth End Sub Private Sub ColorListView(ListView1 As ListView, picGreenbar As PictureBox) Dim i As Integer Dim iFontHeight As Long Dim iBarHeight As Integer Dim ColHead As ColumnHeader Me.ScaleMode = vbTwips picGreenbar.ScaleMode = vbTwips picGreenbar.BorderStyle = vbBSNone picGreenbar.AutoRedraw = True picGreenbar.Visible = False picGreenbar.Font = ListView1.Font iFontHeight = picGreenbar.TextHeight("b") + Screen.TwipsPerPixelY iBarHeight = (iFontHeight * 1) picGreenbar.Width = ListView1.Width '====== picGreenbar.Height = iBarHeight * 2 picGreenbar.ScaleMode = vbUser picGreenbar.ScaleHeight = 2 picGreenbar.ScaleWidth = 1 'draw the actual bars picGreenbar.Line (0, 0)-(1, 1), &HE7E8FC, BF picGreenbar.Line (0, 1)-(1, 2), RGB(0, 255, 0), BF '====== ListView1.PictureAlignment = lvwTile ListView1.Picture = picGreenbar.Image End Sub
采纳哦
采纳哦
全部回答
- 1楼网友:过活
- 2021-11-11 15:32
不知道是不是我理解我這種! 我有!
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯