因此,基本上我一直在尝试为用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
)。
有人可以帮我吗?谢谢:)