int curDifX, curDifY;
bool drag = false;
private void button2_MouseDown(object sender, MouseEventArgs e)
{
curDifX = Cursor.Position.X - button2.Left;
curDifY = Cursor.Position.Y - button2.Top;
drag = true;
}
private void button2_MouseMove(object sender, MouseEventArgs e)
{
if (drag)
{
button2.Left = Cursor.Position.X - curDifX;
button2.Top = Cursor.Position.Y - curDifY;
}
}
private void button2_MouseUp(object sender, MouseEventArgs e)
{
drag = false;
}
|