Foxtable(狐表)用户栏目专家坐堂 → LISTVIEW平铺外框怎么做?


  共有2394人关注过本帖树形打印复制链接

主题:LISTVIEW平铺外框怎么做?

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/3/21 22:34:00 [显示全部帖子]

全局代码

 

Public Sub listView1_DrawItem(ByVal sender As Object, ByVal e As Windows.forms.DrawListViewItemEventArgs)

Dim n As New Pen(Color.Red,2)
Dim rect As new Rectangle(e.Bounds.left-1, e.Bounds.top-1, e.Bounds.width-2, e.Bounds.height-2)
e.Graphics.DrawRectangle(n, e.Bounds)
e.Graphics.DrawImage(sender.LargeImageList(e.Item.ImageIndex), rect)

End Sub

 

生成代码

 

Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
Dim blvw As windows.Forms.Listview = lvw.basecontrol
blvw.OwnerDraw = True
addhandler blvw.DrawItem, addressof listView1_DrawItem


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/3/21 23:16:00 [显示全部帖子]

参考代码

 

Public Sub listView1_DrawItem(ByVal sender As Object, ByVal e As Windows.forms.DrawListViewItemEventArgs)

If e.item.SubItems("性别").text = "男" Then
    Dim n As New Pen(Color.Red,2)
    e.Graphics.DrawRectangle(n, e.Bounds)
Else
    Dim n As New Pen(Color.yellow,2)
    e.Graphics.DrawRectangle(n, e.Bounds)
End If
Dim rect As new Rectangle(e.Bounds.left-1, e.Bounds.top-1, e.Bounds.width-2, e.Bounds.height-2)
e.Graphics.DrawImage(sender.LargeImageList(e.Item.ImageIndex), rect)

End Sub


 回到顶部