SoFunction
Updated on 2025-03-07

Simple example of borderless form movement in C#


Point mouseOff;//Mouse movement position variable
bool leftFlag;//Is the mark left key?
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            if ( == )
            {
mouseOff = new Point(-, -); //Get the value of the variable
leftFlag = true;
            }
        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            if (leftFlag)
            {
                Point mouseSet = ;
(, );  //Set the position after moving
                Location = mouseSet;
            }
        }

        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            if (leftFlag)
            {
leftFlag = false;//Authenticate as false after releasing the mouse;
            }
        }