我有一个面板,我希望通过代码水平滚动, 问题是它似乎只在执行代码行时每隔一秒滚动一次。 这就是我正在使用的
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
.... ... 重复
最佳答案
尝试使用 AutoScrollPosition
代替(并且您需要反转值):
private void MyScrollButton_Click(object sender, EventArgs e) {
MainPanel.AutoScrollPosition = new Point(-MainPanel.AutoScrollPosition.X + 64,
-MainPanel.AutoScrollPosition.Y);
}
关于c# - 如何通过代码滚动面板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10604061/