Reputation: 67
I am devoloping app in Visual Studio using C#. I set no border in my form and I want to make my form dragable.
I need to get position of mouse according to form to get my code work
This is my code to make it dragable
private void timer1_Tick(object sender, EventArgs e)
{
//HERE CODE SET POSITION OF MY FORM
this.Location = new Point(MousePosition.X - MOUSE POSITION ACCORDING TO FORM, MousePosition.Y - MOUSE POSITION ACCORDING TO FORM);
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
timer1.Enabled = true;
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
timer1.Enabled = false;
}
Your answers will be appreciated.
Upvotes: 0
Views: 1384