请教如何用别的控件控制listview作滚动?listview自带的滚动条难看了点。急用

解决方案 »

  1.   

    用SendMessage函数给listview发送LVM_SCROLL 消息:
    窗体,一个按钮,一个listview: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 LVM_FIRST = &H1000
     Private Const LVM_SCROLL = (LVM_FIRST + 20)Private Sub Command1_Click()
        Dim i As Long
        Dim s As String
        s = InputBox("请输入一个整数")
        i = CLng(s) * ListView1.ListItems(1).Height \ Screen.TwipsPerPixelY
        Dim l As Long
        '滚动i行
        l = SendMessage(Me.ListView1.hwnd, LVM_SCROLL, 0, ByVal i)
    End SubPrivate Sub Form_Load()
        Dim i As Long
        Me.ListView1.View = lvwReport
        Me.ListView1.ColumnHeaders.Add , , "test"
        Me.ListView1.HideColumnHeaders = True
        For i = 1 To 200
            Me.ListView1.ListItems.Add , , "line" + CStr(i)
        Next
    End Sub
      

  2.   

    l = SendMessage(Me.ListView1.hwnd, LVM_SCROLL, 0, ByVal i)
    i为负数时,即向上滚动