this.FormBorderStyle = FormBorderStyle.None;
#region窗体移动功能第一种
        privatebool blnState = false;
        privatevoid MoveFrom_MouseDown(object sender, MouseEventArgs e)
        {
            blnState = true;
            ox = e.X;
            oy = e.Y;
        }
        intox = 0;
        intoy = 0;
 
        privatevoid MoveFrom_MouseMove(object sender, MouseEventArgs e)
        {
            try
            {
                if (blnState)
                {
                    this.Location = new Point(this.Location.X- (ox - e.X), this.Location.Y - (oy - e.Y));
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
private voidMoveFrom_MouseUp(object sender, MouseEventArgs e)
        {
            blnState = false;
        }
        #endregion
 
        #region无边框窗体移动 第二种
        privatePoint mouseOffset; //记录鼠标指针的坐标
        privatebool isMouseDown = false;//记录鼠标按键是否按下
 
 
        ///---------------添加三个关于鼠标的事件
        privatevoid Frm_Knowledge_Search_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            intxOffset;
            intyOffset;
 
            if(e.Button == MouseButtons.Left)
            {
                xOffset = -e.X - SystemInformation.FrameBorderSize.Width;
                yOffset = -e.Y - SystemInformation.CaptionHeight -
                SystemInformation.FrameBorderSize.Height;
                mouseOffset = new Point(xOffset,yOffset);
                isMouseDown = true;
            }
        }
 
        privatevoid Frm_Knowledge_Search_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if(isMouseDown)
            {
                Point mousePos = Control.MousePosition;
               mousePos.Offset(mouseOffset.X, mouseOffset.Y);
                Location = mousePos;
            }
        }
 
       private voidFrm_Knowledge_Search_MouseUp(object sender,System.Windows.Forms.MouseEventArgs e)
        {
            //修改鼠标状态isMouseDown的值
            //确保只有鼠标左键按下并移动时,才移动窗体
            if(e.Button == MouseButtons.Left)
            {
                isMouseDown = false;
            }
        }
        #endregion