繁体中文
设为首页
加入收藏
当前位置:程序开发首页 >> Visual Basic >> 如何制作平面式的listview列头

如何制作平面式的listview列头

2008-02-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:在通常情况下,listview的列头是按钮式的,如果你想把列头做成平面式的,那就用我的方法试试,源码如下 Option Explicit Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal h...

在通常情况下,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

责任编辑:admin
相关文章