C#通过鼠标点击panel移动来控制无边框窗体移动

        Point point = new Point(-10, -10);
        bool mouseDown = false;
        private void panelEx5_MouseDown(object sender, MouseEventArgs e)
        {
            mouseDown = true;
            point = e.Location;
        }

        private void panelEx5_MouseMove(object sender, MouseEventArgs e)
        {
            if (mouseDown)
            {
                if (point != e.Location)
                {
                    this.Location = new Point(this.Location.X + (e.Location.X - point.X), this.Location.Y + (e.Location.Y - point.Y));
                    Application.DoEvents();
                }
            }
        }

        private void panelEx5_MouseUp(object sender, MouseEventArgs e)
        {
            mouseDown = false;
            this.Location = new Point(this.Location.X + (e.Location.X - point.X), this.Location.Y + (e.Location.Y - point.Y));
        }
原文地址:https://www.cnblogs.com/qq1223558/p/3209109.html