c# 窗口可移动

private void MonitorDialog_MouseDown(object sender, MouseEventArgs e)
        {
            drag = true;
            X = e.X;
            Y = e.Y;
        }

        private void MonitorDialog_MouseUp(object sender, MouseEventArgs e)
        {
            drag = false;
        }

        private void MonitorDialog_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.Top = Control.MousePosition.Y -Y;
                this.Left = Control.MousePosition.X -X;
            }
        }

你可能感兴趣的:(DoNet)