-1

我正在开发一个 C# 项目,并且我已经删除了表单边框,因此用户无法拖动程序。我需要他们能够通过菜单条或其他工具箱项而不是表单边框进行拖动。

是我的项目的顶部:

4

1 回答 1

0

任何地方点击里面的形式拖动....

    private void Form1_MouseMove(object sender, MouseEventArgs e)
    {
        if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
        {
            Location = new Point(this.Left - (mousePoint.X - e.X), this.Top - (mousePoint.Y - e.Y));
        }
    }

    Point mousePoint = new Point(0, 0);

    private void Form1_MouseDown(object sender, MouseEventArgs e)
    {
        mousePoint = new Point(e.X, e.Y);
    }
于 2016-10-09T05:14:16.627 回答