user4954249
user4954249

Reputation:

Scrollable with the mouse

I have a panning on my usercontrol that for some reason if only the X or only the Y changes it will set the them back to 0. I have it where if x = 0 or y = 0 based on the change equals zero the AutoScrollPosition automatically sets it to the same position as it was before. So if AutoScrollPosition.X = -67, I set the new position in the code to be the previous AutoScrollPosition.X.

        `AutoScrollPosition = Point.Round(New PointF(AutoScrollPosition.X, MouseChange.Y - AutoScrollPosition.Y)) `

The System.Drawing.Point.AutoScrollPosition.X becomes 0 and it shouldn't change. Does anyone know why it does this? Is this a behavior that I should expected from this class and variable?

Upvotes: 0

Views: 62

Answers (1)

user4954249
user4954249

Reputation:

Hans Passant answer

You did it correctly for Y but not for X. You must use -AutoScrollPosition.X, note the negative sign.

Actual answer with code is

AutoScrollPosition = Point.Round(New PointF(-AutoScrollPosition.X, MouseChange.Y - AutoScrollPosition.Y))

Upvotes: 1

Related Questions