如果有东西从面板顶部脱离,则使其到达(0,0)位置,如果在底部,则使其达到(0,Panel Height Size)

时间:2019-03-17 13:00:03

标签: vb.net slider scrollbar custom-controls

因此,基本上我一直在尝试为用VB.NET编写的WinForm编写自定义ScrollBar,但似乎并没有使其受到限制。

无限制尝试的代码:

Public Class GoldSrcScrollBar
    Dim drag As Boolean
    Dim mousey As Integer

    Private Sub GoldSrcScrollBtn1_MouseDown(sender As Object, e As MouseEventArgs) Handles GoldSrcScrollBtn1.MouseDown
        drag = True
        mousey = Cursor.Position.Y - GoldSrcScrollBtn1.Top
    End Sub

    Private Sub GoldSrcScrollBtn1_MouseUp(sender As Object, e As MouseEventArgs) Handles GoldSrcScrollBtn1.MouseUp
        drag = False
    End Sub

    Private Sub GoldSrcScrollBtn1_MouseMove(sender As Object, e As MouseEventArgs) Handles GoldSrcScrollBtn1.MouseMove
        If drag Then
            GoldSrcScrollBtn1.Top = Cursor.Position.Y - mousey
        End If
    End Sub

我不知道如何限制它

Slider = GoldSrcScrollBtn1
ScrollBar Background = GoldSrcScrollBarBg1

没有限制,它是这样的:

如您所见,它脱离了面板(GoldSrcScrollBarBg1)。 有人可以帮我吗?谢谢:)

0 个答案:

没有答案