Results 1 to 13 of 13

Thread: .NET scroll bars-> when you scroll them to maximum position scroll.value is not max

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    .NET scroll bars-> when you scroll them to maximum position scroll.value is not max

    what the heck, I dont understand this at all. I opened a blank project, added two scroll bars, each having a minimum value of 0 and a maximum value of a 100. when I run the program, and I scroll the scrollbars to the maximum value position, it appears that scrollbar.value never goes any higher than 91....

    VB Code:
    1. Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll
    2.         Me.Text = HScrollBar1.Value.ToString
    3.     End Sub
    4.  
    5.     Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
    6.         Me.Text = VScrollBar1.Value.ToString
    7.     End Sub
    would someone try the same thing and see is this happens to you too? because this totally doesnt make any sense to me
    Last edited by MrPolite; Feb 13th, 2004 at 09:07 PM.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    Hyperactive Member dogfish227's Avatar
    Join Date
    Oct 2002
    Location
    GA
    Posts
    409
    yep same here
    Attached Images Attached Images  

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    uuh this is stupid, a big part of my app depends on this scrollbar controls. What the heck!

    Maybe we are doing something wrong? Because it's hard to believe that these controls that have been used over years have a bug
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622
    Nothing wrong with the control, it was designed this way

    See why?
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  5. #5
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    I do not agree that it was designed that way...
    It seems like MS thought it was easier to write a note than to fix the bug.

    Why would they design it that way anyway? I mean, what is it good for?
    VB6 wasn't designed like that...
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  6. #6

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    uuh huh?! what the hell? I agree with pax, I see absolutly no reason whatsoever why someone would NEED to have the scroll bars that way. I don't see any reason why anyone wouldnt want a properly working scrollbar control. Microsoft is stupid
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  7. #7
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622
    If you set the scrollbars.LargeChange Value to 1 then it will fix your problem.
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  8. #8

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by <ABX
    If you set the scrollbars.LargeChange Value to 1 then it will fix your problem.
    well there is a problem with that. The LargeChange property has cetainly a purpose and setting it to 1 all the time would ruin its purpose. When the user clicks on a point on the scrollbar, he/she expects the scrollbar to "jump" to that point, and with the LargeChange set to 1 the scrollbar would only change a tad bit instead of having a large change.

    I would fix it if there was a way to somehow figure out when the user clicks on the up and down arrows on the scrollbar, and when on other parts of the scrollbar, but apparently there isnt a way to do that either
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  9. #9
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi MrPolite

    You can use this inherited class instead of the real scrollbar.

    VB Code:
    1. Public Class MyScroll
    2.     Inherits HScrollBar
    3.  
    4.     Dim OldMax As Integer
    5.  
    6.     Public Shadows Property LargeChange() As Integer
    7.         Get
    8.             Return MyBase.LargeChange
    9.         End Get
    10.         Set(ByVal Value As Integer)
    11.             'To avoid maximum changing when largechange is changed
    12.             OldMax = Me.Maximum
    13.             MyBase.LargeChange = Value
    14.             Me.Maximum = OldMax
    15.         End Set
    16.     End Property
    17.     Public Shadows Property Maximum() As Integer
    18.         Get
    19.             'Return the REAL max
    20.             Return MyBase.Maximum - Me.LargeChange + 1
    21.         End Get
    22.         Set(ByVal Value As Integer)
    23.             'calculate 'virtual' max
    24.             MyBase.Maximum = Value + Me.LargeChange - 1
    25.         End Set
    26.     End Property
    27.  
    28.     Public Sub New()
    29.         'Without this the fix won't work with default maximum value
    30.         Me.Maximum = MyBase.Maximum
    31.     End Sub
    32. End Class
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  10. #10

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by pax
    Hi MrPolite

    You can use this inherited class instead of the real scrollbar.
    Wow thank you


    hmm your code is very simple and yet very complex I would never come up with something like that. Almost works perfectly fine, but still one problem: You wont get the Max value until you release the mouse button I guess I can live with this one

    btw is there a way to use the old scrollbars? if I have to include a file, could someone post the file please? cuz I dont have the old VB
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  11. #11
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    If you are thinking about the scrollbar from the "Grand Ol'e VB6" i think you would need to install the entire VB6. Maybe it's enough to regsvr32 the mscomctl32.dll, but I think there might be a license problem.

    Anyway, you could also use the one in MS Forms 2.0. That would require your end user to have MS Office, but it's the only other way that I can think of.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  12. #12

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    naah
    too much effort needed I'll stick with your version
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  13. #13
    New Member
    Join Date
    Jun 2011
    Posts
    4

    Cool Re: .NET scroll bars-> when you scroll them to maximum position scroll.value is not m

    Quote Originally Posted by pax View Post
    Hi MrPolite

    You can use this inherited class instead of the real scrollbar.

    VB Code:
    1. Public Class MyScroll
    2.     Inherits HScrollBar
    3.  
    4.     Dim OldMax As Integer
    5.  
    6.     Public Shadows Property LargeChange() As Integer
    7.         Get
    8.             Return MyBase.LargeChange
    9.         End Get
    10.         Set(ByVal Value As Integer)
    11.             'To avoid maximum changing when largechange is changed
    12.             OldMax = Me.Maximum
    13.             MyBase.LargeChange = Value
    14.             Me.Maximum = OldMax
    15.         End Set
    16.     End Property
    17.     Public Shadows Property Maximum() As Integer
    18.         Get
    19.             'Return the REAL max
    20.             Return MyBase.Maximum - Me.LargeChange - Me.Minimum  + 1
    21.         End Get
    22.         Set(ByVal Value As Integer)
    23.             'calculate 'virtual' max
    24.             MyBase.Maximum = Value + Me.LargeChange + Me.Minimum - 1
    25.         End Set
    26.     End Property
    27.  
    28.     Public Sub New()
    29.         'Without this the fix won't work with default maximum value
    30.         Me.Maximum = MyBase.Maximum
    31.     End Sub
    32. 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
  •  



Click Here to Expand Forum to Full Width