WinForm窗口拖动

     private Point mypoint;
        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            mypoint = new Point(-e.X, -e.Y);
        }

        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Point myPosition = MousePosition;
                myPosition.Offset(mypoint);
                DesktopLocation = myPosition;
            }
        }

  

posted @ 2023-08-22 16:09  鸑鷟虽孤  阅读(39)  评论(0编辑  收藏  举报