当我们把窗体设成无边框的时候,这个时候我们该怎么样去移动窗体呢,比如说当我们点击移动窗体中的panel控件时,能够移动窗体,在panel控件的MouseDown事件和MouseMove事件中添加以下代码即可:
#region 点击panel控件移动窗口
Point downPoint;
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
downPoint = new Point(e.X, e.Y);
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.Location = new Point(this.Location.X + e.X - downPoint.X,
this.Location.Y + e.Y - downPoint.Y);
}
}
#endregion