如果整个长度恰好是600点,如何将滑块左右部分精确地移动200个点?使用ButtonLeft和ButtonRight按钮...
private void buttonLeft_Click(object sender, EventArgs e)
{
panel1.AutoScrollPosition = new Point(-200, 0);
}
private void buttonRight_Click(object sender, EventArgs e)
{
panel1.AutoScrollPosition = new Point(+200, 0);
}
答案 0 :(得分:0)
如果有错误,请纠正我,但是代码可以正常工作:SL#1 SL#2
private void buttonLeft_Click(object sender, EventArgs e)
{
panel1.AutoScrollPosition = new Point(-panel1.AutoScrollPosition.X - 200);
}
private void buttonRight_Click(object sender, EventArgs e)
{
panel1.AutoScrollPosition = new Point(-panel1.AutoScrollPosition.X + 200);
}
或
private void buttonLeft_Click(object sender, EventArgs e)
{
Point p = panel1.AutoScrollPosition;
panel1.AutoScrollPosition = new Point(-p.X - 200)
}
private void buttonRight_Click(object sender, EventArgs e)
{
Point p = panel1.AutoScrollPosition;
panel1.AutoScrollPosition = new Point(-p.X + 200)
}