private bool click_ = false;
private Point click_point_ = new Point();
public void PictureBox_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && click_ == false)
{
click_ = true;
click_point_.X = e.X;
click_point_.Y = e.Y;
}
}
public void PictureBox_MouseUp(object sender, MouseEventArgs e)
{
click_ = false;
click_point_.X = 0; click_point_.Y = 0;
}
public void PictureBox_MouseMove(object sender, MouseEventArgs e)
{
if ( e.Button == MouseButtons.Left && click_ == true)
{
this.Left += e.X - click_point_.X;
this.Top += e.Y - click_point_.Y;
}
}
마우스를 클릭 후 드래그 할 시 움직임
'Programming > C#' 카테고리의 다른 글
C# 절대값 (0) | 2012.07.12 |
---|---|
C# Save & OpenFileDialog (0) | 2012.07.12 |
C# MouseMove & MouseDown & MouseUp (0) | 2012.07.12 |