VB制作迅雷样式的Listview http://chinajia.com/soft/downinfo/3627.html
按Ctrl+T勾选Microsoft WindowsCommand Controls 6.0 (SP6)
添加1个ListView命名为lv,4个按钮,1个CheckBox,1个PictureBox命名为picBg
'Download by http://www.codefans.net Option Explicit Dim LastCmd As Integer Private Sub Check1_Click() lv.GridLines = Check1.Value End Sub Private Sub Command1_Click() Dim i As Integer LastCmd = 1 picBg.Width = lv.Width picBg.Height = lv.ListItems(1).Height * (lv.ListItems.Count) picBg.ScaleHeight = lv.ListItems.Count picBg.ScaleWidth = 1 picBg.DrawWidth = 1 picBg.Cls For i = 1 To lv.ListItems.Count If lv.ListItems(i).Checked = True Then picBg.Line (0,i - 1)-(1,i),&HC0FFFF,BF Else picBg.Line (0,&HFF8080,BF End If Next lv.Picture = picBg.Image End Sub Private Sub Command2_Click() Dim i As Integer LastCmd = 2 picBg.Width = lv.Width picBg.Height = lv.ListItems(1).Height * (lv.ListItems.Count) picBg.ScaleHeight = lv.ListItems.Count picBg.ScaleWidth = 1 picBg.DrawWidth = 1 picBg.Cls For i = 1 To lv.ListItems.Count If i Mod 2 = 0 Then picBg.Line (0,RGB(242,242,234),BF '&HE0E0E0,BF 'RGB(254,209,199),&HFFFFFF,BF 'RGB(200,125,68),BF End If Next lv.Picture = picBg.Image End Sub Private Sub Command3_Click() lv.Font.Size = 15 Select Case LastCmd Case 1 Command1_Click Case 2 Command2_Click End Select End Sub Private Sub Command4_Click() Dim i As Integer LastCmd = 1 picBg.Width = lv.Width picBg.Height = lv.ListItems(1).Height * (lv.ListItems.Count) picBg.ScaleHeight = lv.ListItems.Count picBg.ScaleWidth = 1 picBg.DrawWidth = 1 picBg.Cls For i = 1 To lv.ListItems.Count Select Case i Mod 5 Case 0 picBg.Line (0,&HC0E0FF,BF Case 1 picBg.Line (0,&HC0FFC0,BF Case 2 picBg.Line (0,&HFFC0FF,BF Case 3 picBg.Line (0,&HE0E0E0,BF Case 4 picBg.Line (0,&H8000&,BF End Select Next lv.Picture = picBg.Image End Sub Private Sub Form_Load() Dim i As Integer Dim mRow As ListItem Me.ScaleMode = vbTwips '--------------------------- '初始化 '-------------------------- lv.Appearance = ccFlat lv.View = lvwReport lv.FullRowSelect = True lv.CheckBoxes = True lv.ColumnHeaders.Add,"序号",600 lv.ColumnHeaders.Add,"标题",3000 For i = 0 To 10 Set mRow = lv.ListItems.Add(,CStr(i)) mRow.SubItems(1) = "这是一个listview换色实例 " & i Next lv.ListItems(1).Checked = True lv.ListItems(3).Checked = True lv.ListItems(2).Checked = True lv.ListItems(6).Checked = True lv.ListItems(4).Checked = True lv.ListItems(3).Checked = True '------------------------- '图片样式 '------------------------ picBg.BackColor = lv.BackColor picBg.ScaleMode = vbTwips picBg.BorderStyle = vbBSNone picBg.AutoRedraw = True picBg.Visible = False '--------------------------- Check1.Caption = "显示网格" Check1.Value = 1 Command1.Caption = "样式1(选中区分)" Command2.Caption = "样式2(迅雷样式)" Command3.Caption = "改变字体" Command4.Caption = "样式3(多彩间隔)" End Sub