Scrolling inside a control from the code is very simple.
All you have to do is to give the control the new location (Point: x,y)
and it will scroll to the new point...
My generic method scrolls the item each time by ~66% of its size (2/3)
Note: in my example, the scrolling obect is this!
int changeHeight = this.Height * 2 / 3;
if (p_pressedKey == Keys.Down)
{
this.AutoScrollPosition = new Point(this.AutoScrollPosition.X, -this.AutoScrollPosition.Y + changeHeight);
}
else if (p_pressedKey == Keys.Up)
{
this.AutoScrollPosition = new Point(this.AutoScrollPosition.X, -this.AutoScrollPosition.Y - changeHeight);
}
No comments:
Post a Comment