How to add a scrollbar to a custom control
-
Hello, I hope someone can point into the right direction with this question: I have a custom control which inherits from System.Windows.Forms.Control. This control requires scrolling but I'm unsure how to add the scrollbars. I see three options: - Add WS_HSCROLL and WS_VSCROLL flags in method CreateParams This feels like the right way to go because windows takes care of most of the scrollbar issues (like allignment). However, I found little support for this implementation in .Net. A method like SetScrollInfo is not part of the .Net implementation and can only be used after importing it from user32.dll. - Adding a VScrollBar and HScrollBar to the control. I think this could work, but extra code is needed to keep the scrollbars properly aligned and to adjust the client rectangle with the space occupied by the scrollbars. - Inheriting from System.Windows.Forms.ScrollableControl Because my component is like a grid and I want to handle painting, scrolling and most/all other events myself, I don't think this is the proper control to inherit from. Also, a ScrollableControl supports docking of other controls (a user can drag a button on the control) which I want to be dissabled. All your information is welcome. Regards, Kees Vermeulen info@kever.com