我有一个Panel,希望在代码中水平滚动, 问题是它似乎只是每隔一次滚动执行代码行。 这就是我使用的
private void MyScrollButton_Click(object sender, EventArgs e)
{
MainPanel.HorizontalScroll.Value += 64;
}
每次都会发生这种情况,
1st Click: Panel Scrolls and ScrollBar Remains Still
2nd Click: Panel remains still and ScrollBar scrolls
3rd Click: Same as 1st
4th Click: Same as 2nd
.... ... 重复
答案 0 :(得分:4)
尝试使用AutoScrollPosition
代替(您需要反转该值):
private void MyScrollButton_Click(object sender, EventArgs e) {
MainPanel.AutoScrollPosition = new Point(-MainPanel.AutoScrollPosition.X + 64,
-MainPanel.AutoScrollPosition.Y);
}