文章探索:   分类:    关键字:  
  + 栏目导航
  + 相关文章
文本框中光标位置的获得
用VB导入导出你的IE收藏夹
VB应用程序访问SQL Server方法探讨
VB访问SQL Server数据库技术全揭密
自动上网抓数据的机器人
自己的IE——用VB制作浏览器
VB中如何保存Webbrowser中的整个页面..
在VB中该如何控制其它程序的弹出窗口..
保存webbrowser中的HTML内容
破译动网验证码的简单方法
轻松获取QQ密码
VB.NET获取硬盘序列号的方法
WEBBROWSER 技巧一(收藏)
VB自动登陆网络站点详解(二):Inet..
获取webbrowser控件网页的源码
WebBrowser控件说明
关于用VB做更漂亮的窗体的思考
VB中访问存储过程的几种办法
VB6中改变屏幕的分辨率和刷新频率
VB编写一个能显示百分比的自定义进度..
公农历转换VB类
VB.NET窗口渐淡关闭
使用VB实现邮箱自动注册(二):修改..
VB.NET轻松实现任务栏程序
VB.NET启动外部程序
利用vb实现图片上传
VB实现局域网内的文件传输
VB 一个Function传回多个值
在VB中实现多线程
VB 手机号码编码程序


技术教程 -> VB教程 ->  
给Listview做个背景
来源:转载   人气:797   录入时间:2007-11-8
     Private Sub Command1_Click()
    lvList.GridLines = Not lvList.GridLines
   
    SetBackColor lvList, vbRed, vbWhite
   
   End Sub
   
   
   Private Sub Form_Load()
   
   Dim i As Long, lvItem As ListItem
   
    For i = 1 To 450
   
    Set lvItem = lvList.ListItems.Add(, , "演示 " & i)
   
    If i Mod 2 = 0 Then lvItem.Checked = True Else lvItem.Checked = False
   
    Next i
   
   
   
    SetBackColor lvList, picBoard, vbRed, vbGreen
   
   End Sub
   
   
   Private Function SetBackColor(lvList As ListView, picBoard As PictureBox, CheckColor As ColorConstants, unCheckColor As ColorConstants)
   
   Dim iWidth As Single, iHeight As Single, tHeight As Single, lMatch As Single
   
   Dim i As Long
   
    With picBoard
   
    .AutoRedraw = True
   
    .BackColor = lvList.BackColor
   
    .Cls
   
    .Visible = False
   
    .ScaleMode = vbTwips
   
    .Width = lvList.Width + 100
   
    .Height = lvList.ListItems(1).Height * (lvList.ListItems.Count + 1)
   
    With .Font
   
    .Size = lvList.Font.Size + 2.75
   
    .Bold = lvList.Font.Bold
   
    .Charset = lvList.Font.Charset
   
    .Italic = lvList.Font.Italic
   
    .Name = lvList.Font.Name
   
    .Strikethrough = lvList.Font.Strikethrough
   
    .Underline = lvList.Font.Underline
   
    .Weight = lvList.Font.Weight
   
    End With
   
   
   
    iWidth = .Width
   
   
    For i = 1 To lvList.ListItems.Count
   
    If i = 1 Then lMatch = lvList.ListItems(i).Top - lvList.ListItems(i).Height
   
    tHeight = lvList.ListItems(i).Top - lvList.ListItems(i).Height - lMatch
   
    iHeight = lvList.ListItems(i).Height
   
    If lvList.ListItems(i).Checked Then
   
    picBoard.Line (0, tHeight)-(iWidth, tHeight + iHeight), CheckColor, BF
   
    Else
   
    picBoard.Line (0, tHeight)-(iWidth, tHeight + iHeight), unCheckColor, BF
   
    End If
   
    Next
   
    End With
   
    lvList.Picture = picBoard.Image
   
   End Function




Copyright(C)2007-2024 广州市佳沛数码科技有限公司 版权所有
公司地址: 广州市荔湾区东漖北路560号511室
电话:020-81803473 传真:020-81544987