如何移动滑块自动滚动(按钮)

时间:2018-12-23 05:48:02

标签: c# .net winforms

如果整个长度恰好是600点,如何将滑块左右部分精确地移动200个点?使用ButtonLeft和ButtonRight按钮...

two muppets

two muppets

two muppets

two muppets

    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);
    }

1 个答案:

答案 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)
    }