欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Winform窗体移动

程序员文章站 2022-06-08 16:10:40
...
        private Point point;
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            point = new Point(e.X, e.Y);
        }

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

即可

相关标签: C#窗体移动