TreeView自定义垂直滚动条

时间:2012-01-05 15:10:33

标签: windows vb.net winforms

我有一个.NET 3.5 WinForms应用程序,我已经实现了自定义水平& TreeView的垂直滚动条。但是,如果一个节点有子节点,它将不允许您滚动子节点。

我要滚动的子程序如下

Private Sub vsbLayers_Scroll(sender As System.Object, e As System.Windows.Forms.ScrollEventArgs) Handles vsbLayers.Scroll
    Try
        If e.Type = ScrollEventType.SmallIncrement OrElse e.Type = ScrollEventType.LargeIncrement Then
            tvLayers.Nodes(e.NewValue + _visible).EnsureVisible()
        ElseIf e.Type = ScrollEventType.SmallDecrement OrElse e.Type = ScrollEventType.LargeDecrement Then
            tvLayers.Nodes(e.NewValue).EnsureVisible()
        ElseIf (e.Type = ScrollEventType.ThumbTrack) Then
            If e.NewValue > e.OldValue Then
                tvLayers.Nodes(e.NewValue + _visible).EnsureVisible()
            ElseIf e.NewValue = e.OldValue Then
                'Needed to ensure the layers list does not jump up one when you just click on the thumb
            Else
                tvLayers.Nodes(e.NewValue).EnsureVisible()
            End If
        End If
        Application.DoEvents()
        If hsbLayers.Enabled Then
            Dim y As Integer = GetTreeViewScrollPos(tvLayers).Y
            Dim pt As New Point(0, y)
            SetTreeViewScrollPos(tvLayers, pt)
            hsbLayers.Value = 0
        End If
    Catch ex As Exception
        LogError(ex.ToString)
    End Try
End Sub

我确定我需要做一些事情,看一个节点是否有子节点&滚动它们但我不知道该怎么做。有人建议看什么?

0 个答案:

没有答案