|
bool isMouseDown = false;
Point mouseOffset;
private void label1_MouseUp (object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isMouseDown = false;
}
}
private void label1_MouseMove (object sender, MouseEventArgs e)
{
if (isMouseDown)
{
Point mousePos = Control.MousePosition;
mousePos.Offset (mouseOffset.X, mouseOffset.Y);
this.Location = mousePos;
}
}
private void label1_MouseDown (object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mouseOffset = new Point (-e.X, -e.Y);
isMouseDown = true;
}
}
I want to implement a Label drag, but as soon as I drag the mouse to the 0,0 coordinates of the Form, what is going on?
Besides, how can you drag the controls? |
|