解决方法
除了我的其他答案,您可以在控件中手动执行此操作,如下所示:
Point dragOffset; protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button == MouseButtons.Left) { dragOffset = this.PointToScreen(e.Location); var formLocation = FindForm().Location; dragOffset.X -= formLocation.X; dragOffset.Y -= formLocation.Y; } } protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (e.Button == MouseButtons.Left) { Point newLocation = this.PointToScreen(e.Location); newLocation.X -= dragOffset.X; newLocation.Y -= dragOffset.Y; FindForm().Location = newLocation; } }
编辑:测试和修复 – 现在实际上工作.