How do I make mousedrag inside Panel move form window?

c#, winforms

Solution

You can achieve it by using the MouseMove Event of the panel

Example should be something like this (Sorry have not tested it)

private void panel1_MouseMove(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Left)
    {
        this.Location = new Point(Cursor.Position.X + e.X , Cursor.Position.Y + e.Y);
    }
}

Problem

I have this System.Windows.Forms.Panel that I want to enable so that if the user click and drags the mouse drags the window around to. Can I do this? Do i have to implement multiple events?

Original source