我将表单中的边框设置为null / none,所以现在我无法移动表单..所以我发现这段代码并不紧张,因为我的整个表单是由面板组成的:
private bool dragging = false;
private Point dragCursorPoint;
private Point dragFormPoint;
private void HomeScreen_MouseDown(object sender, MouseEventArgs e)
{
dragging = true;
dragCursorPoint = Cursor.Position;
dragFormPoint = this.Location;
}
private void HomeScreen_MouseMove(object sender, MouseEventArgs e)
{
if (dragging)
{
Point dif = Point.Subtract(Cursor.Position, new Size(dragCursorPoint));
this.Location = Point.Add(dragFormPoint, new Size(dif));
}
}
private void HomeScreen_MouseUp(object sender, MouseEventArgs e)
{
dragging = false;
}
HomeScreen表格鼠标事件并不紧张,因为表格填充了面板。所以我应该以某种方式将面板点击链接到表单点击(鼠标事件)。有没有办法做到这一点,所以我可以从我想要的任何地方移动我的表格?