打印本文 打印本文 关闭窗口 关闭窗口
如何制作平面式的listview列头
作者:武汉SEO闵涛  文章来源:敏韬网  点击数703  更新时间:2009/4/23 18:59:27  文章录入:mintao  责任编辑:mintao

在通常情况下,listview的列头是按钮式的,如果你想把列头做成平面式的,那就用我的方法试试,源码如下

Option Explicit

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Const GWL_STYLE = (-16)
Private Const LVM_FIRST = &H1000
Private Const LVM_GETHEADER = (LVM_FIRST + 31)
Private Const HDS_BUTTONS = &H2

Private Sub Form_Load()

Dim hHeader As Long, lStyle As Long
Dim i As Integer
ListView1.View = lvwReport
With ListView1.ColumnHeaders
.Add , , "编号", 500, lvwColumnLeft
For i = 1 To 10
.Add , , "内容项" & i, 1000, lvwColumnRight
Next
End With

hHeader = SendMessage(ListView1.hWnd, LVM_GETHEADER, 0, ByVal 0&)
lStyle = GetWindowLong(hHeader, GWL_STYLE)
SetWindowLong hHeader, GWL_STYLE, lStyle Xor HDS_BUTTONS
End Sub


打印本文 打印本文 关闭窗口 关闭窗口