Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What is happening with your scrollbar is the following: when the user interacts with the scrollbar causing the event and your event handler is called the property value have not yet been updated, after you event handler returns the property is set internally by the scrollbar overwriting the value you set and causing the "jump back" effect you mention. How does it remember what value it have to set? Easy: it's in e.NewValue. And that's exactly your solution, to be able to correctly way to alter the final value of this property during the scroll event just write to e.NewValue as follows:</p> <pre><code>int difference = e.NewValue - e.OldValue; if (e.Type == ScrollEventType.SmallIncrement) { if (difference != scrollBar.SmallChange) { int increase = (scrollBar.SmallChange - difference); scrollBar.Maximum += increase; e.NewValue = scrollBar.Value + increase; } } </code></pre> <p>I want to link theese pages that may be relevant to you: <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.scrollbar.maximum.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.windows.forms.scrollbar.maximum.aspx</a></p> <p>Note in remarks (This is why even moving the Maximun you still get it advance only 1): </p> <blockquote> <p>The maximum value can only be reached programmatically. The value of a scroll bar cannot reach its maximum value through user interaction at run time. The maximum value that can be reached through user interaction is equal to 1 plus the Maximum property value minus the LargeChange property value. If necessary, you can set the Maximum property to the size of the object -1 to account for the term of 1.</p> </blockquote> <p><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.scrollbar.scroll.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.windows.forms.scrollbar.scroll.aspx</a> <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.scrolleventargs.newvalue.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.windows.forms.scrolleventargs.newvalue.aspx</a> (Gets or sets the new Value of the scroll bar. [Emphasis in sets])</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload