自动调整listview标题头宽度的二种方法

自动调整listview标题头宽度的二种方法

方法一:
'*******************************
'用法:Call ResizeListView(ListView1)
'*******************************
Public Sub ResizeListview(objListView As ListView)
    Dim dSecWidth As Double
    Dim iLoop As Integer
    With objListView
         dSecWidth = (.Width / .ColumnHeaders.Count) - 30
         For iLoop = 1 To .ColumnHeaders.Count
          .ColumnHeaders(iLoop).Width = dSecWidth
          '// DoEvents [ Optional, don't really need it ]
         Next iLoop
    End With
End Sub

方法二(使用API):
'**********************
'API声明
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const LVM_FIRST = &H1000
'函数
Public Sub AutoSizeColumnHeader(LView As ListView, Column As ColumnHeader, ByVal SizeToHeader As Boolean)
    Dim l As Long
    If SizeToHeader Then l = -2 Else l = -1
    Call SendMessage(LView.hWnd, LVM_FIRST + 30, Column.Index - 1, l)
End Sub
 

阅读更多
个人分类: VB 6.0
上一篇怎么查找数据库中的某个字段
下一篇水水
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭