private static int intX = 0;
private static int intY = 0;
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
intX = -e.X;
intY = -e.Y;
}
private void panel1_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point myPosition = Control.MousePosition; //获取当前鼠标的屏幕坐标
myPosition.Offset(intX, intY); //重载当前鼠标的位置
this.DesktopLocation = myPosition; //设置当前窗体在屏幕上的位置
}
}