我想用C#鼠标移动一个按钮 我在stackoverflow上找到了这个解决方案
private Point MouseDownLocation;
private void MyControl_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
MouseDownLocation = e.Location;
}
}
private void MyControl_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
(button)sender.Left = e.X + (button)sender.Left -MouseDownLocation.X;
(button)sender.Top = e.Y + (button)sender.Top - MouseDownLocation.Y;
}
}
我希望有人可以向我解释
有什么区别
e.X
(这是mousemoving eventArgs的坐标)和MouseDownLocation.X