Adding scrollbars to UserControl

11,209

Set the AutoScrollMinSize property.

If you implemented the OnPaint() override then you'll need to use the AutoScrollPosition property to set the arguments for e.Graphics.TranslateTransform().

Share:
11,209
Bevin
Author by

Bevin

Updated on June 04, 2022

Comments

  • Bevin
    Bevin almost 2 years

    I am trying to add vertical and horizontal scrollbars to my UserControl with the HorizontalScroll and VerticalScroll properties, but I am having extreme issues. My problem arises when I drag or manipulate the scroll box on the bar. When I let it go, it simply jumps back to the start position!

    I know of the AutoScroll property, but I do not want to use it since I want to be able to control every aspect of my scrollbars, and I don't want it to be done automatically. Also, according to the documentation, AutoScroll is for "[enabling] the user to scroll to any controls placed outside of its visible boundaries" which isn't what I want. I just want scrollbars.

    ...aaand I suppose I could add VScrollBar and HScrollBar to the control, but why should I do this when the scroll functionality already exists? Seems like a waste to me.