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

无边框窗体移动

程序员文章站 2022-07-14 12:20:51
...
 
  private int x;
        private int y;
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            this.x = e.X;
            this.y = e.Y;
        }
        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.Location = new Point(this.Location.X + e.X - this.x, this.Location.Y + e.Y - this.y);
            }
        }