This article show how to customize a
to use effectively scrollbars (
) without setting the
property (you must not set
). In most cases, you can use the
AutoScroll = true
. But in some cases, when you must work with two panels and separate
s, then you can use this
control. For example: if you will show 24 pictures just one by one on a scrollable panel, then you can set the Minimum of the
and the Maximum to
. You can change Enable or Visible property of each scrollbar of the panel, receive a scrolling event, and change and receive the positions of both scrollbars.
The Codeproject article "Customize a panel with Autoscroll property
" by Manalee software gives the inspiration.
Using the Code
In your solution, add the file ManualScrollPanel.cs
to your C# project. Then you can change type of a panel in your project by the
type. Now you can set the
values to the
(Enabled, Minimum, Maximum, SmallChange, LargeChange, Value, Visible) like you want.
In the example with the Form, you can see how the scroll is working.
Explanations about code in the
First you must create a new class that overrides the
. In the constructor code, you must set the protected properties
. It is not possible to do this later on. You also must override the
function to receive API32 scrolling messages (
). These messages must not pass to the base class. In
was done a calculation for the new scroll value. If there is a new value then the
That's all, enjoy with it in the hope that it will be useful for you...
Version 1.0 (Initial Release): All described features implemented. If you need the mousewheel, you have to do extra stuff.