This is a discussion on scrollbar thumbtrack woes - DOTNET ; I am having some issues with the standard Windows scrollbar. I am using MS Visual Studio 2005. Code is C#. The application is a Windows Forms app. The tool is a vertical scroll bar from the toolbox. I am attempting ...
I am having some issues with the standard Windows scrollbar. I am using MS
Visual Studio 2005. Code is C#. The application is a Windows Forms app. The
tool is a vertical scroll bar from the toolbox.
I am attempting to perform a simple operation on a global class variable
(not a methods local variable) such as an integer increment (like myInt++ ).
Grabbing the scroll bar and dragging it produces the thumbtrack event in the
scroll method. I notice that if I grab the scroll bar and drag it down
quickly, the variable is only incremented occasionally. If I drag it slowly
enough, the variable is incremented correctly.
The scroll method seems to be called, but the variable is not updated. The
other scroll events ( SmallIncrement, SmallDecrement etc) are slow enough to
allow the variable to be updated correctly.
How can I get the variable to be updated each time the scroll thumbtrack
Here's the code to reproduce the problem. Very simple.
public partial class Form1 : Form
int myInt = 0;
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
if (e.Type == ScrollEventType.ThumbTrack)
textBox1.Text = Convert.ToString(myInt);
} // end method
} // end class
} // end namespace