|
-
Jul 1st, 2015, 04:28 PM
#10
New Member
Re: .NET scroll bars-> when you scroll them to maximum position scroll.value is not m
 Originally Posted by pax
Hi MrPolite
You can use this inherited class instead of the real scrollbar.
VB Code:
Public Class MyScroll
Inherits HScrollBar
Dim OldMax As Integer
Public Shadows Property LargeChange() As Integer
Get
Return MyBase.LargeChange
End Get
Set(ByVal Value As Integer)
'To avoid maximum changing when largechange is changed
OldMax = Me.Maximum
MyBase.LargeChange = Value
Me.Maximum = OldMax
End Set
End Property
Public Shadows Property Maximum() As Integer
Get
'Return the REAL max
Return MyBase.Maximum - Me.LargeChange - Me.Minimum + 1
End Get
Set(ByVal Value As Integer)
'calculate 'virtual' max
MyBase.Maximum = Value + Me.LargeChange + Me.Minimum - 1
End Set
End Property
Public Sub New()
'Without this the fix won't work with default maximum value
Me.Maximum = MyBase.Maximum
End Sub
End Class
Granted this post is old, but it is still relevant. My scroll bar is 1 based and not 0 based.
I was having a problem when I scrolled to max, It would get "Stuck" there until I altered the scroll.value.
So, I made a small tweak to your code, because not ever scrollbar is going to be zero based. So in the get and set I added Me.Minimum to the calculations.
Now even if Minimum is 5, the scrollbar will scroll properly. Thanks for a nice starting point.
And for the coder who was mentioning that the max isn't actually reached until you release the mouse button, It is that way on a standard scrollbar as well.
I always set my Minimum first, so I didn't see the need for shadowing that property.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|