HScrollBar logic quirks

Cyrilix

2[H]4U
Joined
Jan 21, 2005
Messages
2,188
Basically, what I'm trying to do is get a horizontal scroll bar to redraw an image inside a picture box, though, I'm not quite understanding how the Value property of the scroll bar is acquired. I know that the value depends on where the scroll bar position is currently at, however, from my tests, I set the HScrollBar.Maximum to 50, and no matter how much I try to scroll, the highest Value I can pick up is 36. For reference, the lowest Value I get is 0, which is intuitively correct. Why is this? My initial belief was that depending on the Minimum and Maximum, the scroll bar would resize itself so that you could go from Minimum to Maximum (Minimum being the scroll bar position all the way to the left, and Maximum being the scroll bar position all the way to the right), but it seems like this is not the case.
 
man... one of the good things about java is JScrollPane. i still have mixed feelings about java but at least is has a built-in scroll pane. i know that doesn't help, assuming .net, though perhaps you should provide the language you're using
 
Which layer over which library are you using, on which OS? Can you show your code, or are we left to speculate blindly?
 
Basically, what I'm trying to do is get a horizontal scroll bar to redraw an image inside a picture box, though, I'm not quite understanding how the Value property of the scroll bar is acquired. I know that the value depends on where the scroll bar position is currently at, however, from my tests, I set the HScrollBar.Maximum to 50, and no matter how much I try to scroll, the highest Value I can pick up is 36. For reference, the lowest Value I get is 0, which is intuitively correct. Why is this? My initial belief was that depending on the Minimum and Maximum, the scroll bar would resize itself so that you could go from Minimum to Maximum (Minimum being the scroll bar position all the way to the left, and Maximum being the scroll bar position all the way to the right), but it seems like this is not the case.

Well, did you change the SmallChange and LargeChange property values? Also, did you read the example on this MSDN page? They add the large change to the maximum as part of their solution (I think this takes care of the situation where the bar itself has width.)

EDIT: Mike, I just made the assumption that this is .NET 2.0 and he's using a Windows Form. He asked a question about Forms a few days ago so I'm further speculating this is somehow related to that query. :)

202276
 
Ah, sorry about that. I'm using C# with .NET 2.0 on Windows XP 32-bit. For some reason, I just tend to assume that people might've heard of what I'm talking about.

@Tytalus: Doh, I should've read that myself. 1 + Maximum - LargeChange = 36. It all makes sense now.

"The maximum value that can be reached through user interaction is equal to 1 plus the Maximum property value minus the LargeChange property value."

I don't know why they do this, because it just doesn't make any sense at all.
 
Well, as a quick item not directly related to the question:

In .NET 3.0 and .NET 3.5 there's a fun control called ScrollViewer. It simplifies the process of displaying graphical content within a scroll window (as is described in the link I provided.)

It has a Content property that you set (often to a container, like a GridView, StackPanel, etc.) and it does the rest. We've had a ton of success with it by using a Canvas in a ScrollViewer then sizing the Canvas to the size of the content contained on said Canvas (i.e. a rendered AutoCAD file, a BMP/JPG, etc.) It does a great job of ensuring the scrollbars show up when needed, and after hooking on to the appropriate events it gives you all the info needed to adjust the underlying content (if needed.)

202276
 
Back
Top