c# MoveDown事件中使窗体移动

来源:百度知道 编辑:UC知道 时间:2024/09/25 00:34:04
紧急!^^

这么写就行
bool isDown = false;
Point startPoint;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
isDown = true;
startPoint = e.Location;
}

private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (isDown && e.Button == MouseButtons.Left)
{
this.Location += new Size(e.X - startPoint.X, e.Y - startPoint.Y);
}
}

private void Form1_MouseUp(object sender, MouseEventArgs e)
{
isDown = false;
}

MouseDown
MouseMove
MouseUp
写3个事件

是MouseMove事件

没说清楚问题。