private Point mousePos; //mouse_位置_記録
private bool beginmove=false; //移動_かどうか_記録
private void button1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(beginmove)
{
int diffx,diffy;
diffx = mousePos.X - e.X;
diffy = mousePos.Y - e.Y;
this.button1.Location = new Point(button1.Location.X-diffx,button1.Location.Y-diffy);//buttonの位置変化
}
}
private void button1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
beginmove=true;//移動始め
mousePos=new Point(e.X,e.Y);
}
private void button1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
beginmove = false;//移動終わり
}