Make a borderless form movable?

前端 未结 21 2225
情歌与酒
情歌与酒 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:28

    Adding a MouseLeftButtonDown event handler to the MainWindow worked for me.

    In the event function that gets automatically generated, add the below code:

    base.OnMouseLeftButtonDown(e);
    this.DragMove();
    

提交回复
热议问题