第一步:声明全局变量->  private Point _HoverTreePosition;

第二步:

#region 隐藏标题栏后移动窗口
private void Form_HoverTree_MouseDown(object sender, MouseEventArgs e)
{
_HoverTreePosition.X = e.X;
_HoverTreePosition.Y = e.Y;
}

private void Form_HoverTree_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point h_myPosittion = MousePosition;
h_myPosittion.Offset(-_HoverTreePosition.X, -_HoverTreePosition.Y);
Location = h_myPosittion;
}
}
#endregion

第三步:在窗体上绑定MouseDown、MouseMove两个方法

版权声明:本文为zhuangjolon原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/zhuangjolon/p/9238658.html