C#中实现鼠标拖动窗体的方法

用C#实现鼠标拖动窗体,方法可能有很多,不过我想最好多还应该是直接记录鼠标的位置,进而完成操作:

private void AddList_MouseDown(object sender, MouseEventArgs e)
        {
            //   Gets   the   x-coordinate   and   y-coordinate   of   a   mouse   click   based   on   the   the   client   area   of   the   form   
            mouse_offset = new Point(-e.X, -e.Y); 
        }

        private void AddList_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                //   Gets   the   position   of   the   mouse   cursor   in   screen   coordinates   
                Point mousePos = Control.MousePosition;
                //   Translates   this   Point   by   the   specified   amount.   
                mousePos.Offset(mouse_offset.X, mouse_offset.Y);
                Location = mousePos;
            }   

        }
原文地址:https://www.cnblogs.com/MicroGoogle/p/1703898.html