scrollbar.scroll event occuring twice

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am curious as to why the scrollbar.scroll event gets called twice

Here is an example of my code
Private Sub vsbMoveCar_Scroll(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.ScrollEventArgs) Handles vsbMoveCar.Scrol
'Position the up and down movemen
'Used when the scroll box is move

picCar.Top = vsbMoveCar.Valu
X +=
Label1.Text = CStr(X

End Su

When I click on the scrollbar X gets incremented twice. Why is this event being called twice? I would greatly appreciate some insight into this

I know that there is a keydown and keyup event, but I don't think this is what's doing it.
 
Check the type member of the ScrollEventArgs variable. It will be one of the
ScrollEventType members such as LargeIncrement, SmallIncrement, EndScroll,
etc. I suspect that you are getting an EndScroll message sent after the
Increment/Decrement message. Simply check to see that the type is indicating
that a scrollbar movement actually occurred and that it's not signalling the
end of the movement.

Scott


johnperkins said:
I am curious as to why the scrollbar.scroll event gets called twice.

Here is an example of my code:
Private Sub vsbMoveCar_Scroll(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.ScrollEventArgs) Handles vsbMoveCar.Scroll
'Position the up and down movement
'Used when the scroll box is moved

picCar.Top = vsbMoveCar.Value
X += 1
Label1.Text = CStr(X)


End Sub

When I click on the scrollbar X gets incremented twice. Why is this event
being called twice? I would greatly appreciate some insight into this.
 
Back
Top