Dynamically set a ScrollBar based on form size

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • robkeithd
    New Member
    • Sep 2008
    • 1

    #1

    Dynamically set a ScrollBar based on form size

    Greetings,

    In a nutshell: I've got a panel sitting on a form that is docked to full sitting next to a vertical scrollbar that is docked left. There is a picture control sitting in the panel that may be larger than the viewable area of the panel. I'm trying to set the scrollbar up dynamically when the user resizes the form but it doesn't seem to take. For example: the user can see half of the image so the scrollbar maximum gets set to 2. When the value is 0 I set the picture top to zero so the user sees the top half and when the value is 1 I set the picture top such that the user sees the bottom half. Now the user resizes the form so only 1/4 of the image is visible. The scrollbar max is set to 4 but the scrollbar still only allows me to set the value to either 0 or 1 and not 0,1,2 or 3 as would expect. Am I missing some other property that needs to bet set or something? Any other ideas?

    Thanks

    Robert D
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Create a method that fires on the form's SizeChanged event, that will recalculate your values.

    SizeChanged fires every time DURING the changing of the form's size.
    You might what to check if the mouse button is down in this method so you don't redraw/recalculate for ever 1 pixel change in size during the movement.

    I *think* there is also a SizeChangeCompl ete event that happens just once when the user lets up on the mouse after size changing, but I'm not at my Dev computer to confirm that.

    Comment

    Working...