Drag the form endlessly

This method uses your own code to implement, copy this code into the interface code, and then select a control in the form, such as Panel or Label, and bind their MouseDown event to the MouseDown event and MouseMove event in the code. You can bind the MouseMove event in the code.
Point mPoint;

    private void Panel_MouseDown(object sender, MouseEventArgs e)
    {
        mPoint = new Point(e.X, e.Y);
    }

    private void Panel_MouseMove(object sender, MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left)
        {
            this.Location = new Point(this.Location.X + e.X - mPoint.X, this.Location.Y + e.Y - mPoint.Y);

        }
    }

Guess you like

Origin blog.csdn.net/Hat_man_/article/details/115340237