0

I set the border in the form to null/none so now I can't move the form.. So I found this code which is not firring because my whole form is made of panels:

    private bool dragging = false;
    private Point dragCursorPoint;
    private Point dragFormPoint;

    private void HomeScreen_MouseDown(object sender, MouseEventArgs e)
    {
        dragging = true;
        dragCursorPoint = Cursor.Position;
        dragFormPoint = this.Location;
    }

    private void HomeScreen_MouseMove(object sender, MouseEventArgs e)
    {
        if (dragging)
        {
            Point dif = Point.Subtract(Cursor.Position, new Size(dragCursorPoint));
            this.Location = Point.Add(dragFormPoint, new Size(dif));
        }
    }

    private void HomeScreen_MouseUp(object sender, MouseEventArgs e)
    {
        dragging = false;
    }

HomeScreen Form Mouse Event are not firring because the Form is filled with panels. So somehow I should link the panel clicks to the form clicks (mouse event). Is there a way to do that so I can move my form from wherever I want too?

  • Use exact code of [this answer](http://stackoverflow.com/a/1592899/3110834) and handle `MouseDown` event of all panels using the same method in the answer. – Reza Aghaei Jun 24 '16 at 07:42
  • Well, just use one more panel. Dock it to the top, make it about 30 pixels tall, give it a distinct color. You can draw a description of the window, perhaps draw an X. And now both you and your user will know how to move the window. – Hans Passant Jun 24 '16 at 07:47
  • Did that, works, sorry for duplicate – Forgacs Norbert Jun 24 '16 at 08:12

0 Answers0