Make a borderless form movable?

前端 未结 21 2190
情歌与酒
情歌与酒 2020-11-22 09:48

Is there a way to make a form that has no border (FormBorderStyle is set to \"none\") movable when the mouse is clicked down on the form just as if there was a border?

21条回答
  •  生来不讨喜
    2020-11-22 10:23

    For .NET Framework 4,

    You can use this.DragMove() for the MouseDown event of the component (mainLayout in this example) you are using to drag.

    private void mainLayout_MouseDown(object sender, MouseButtonEventArgs e)
    {
        this.DragMove();
    }
    

提交回复
热议问题