How do I double-click a borderless form to resize it?

77 Views Asked by At

I'm writing a WinForms app with a borderless form. In a regular form, you can double-click on the title bar to toggle its WindowState between Maximized and Normal. How can I do this with a borderless form?

Here's my code for the menu's MouseDoubleClick event handler...

        private void MnuMain_MouseDoubleClick(object sender, MouseEventArgs e)
    {
        // The main menu (MnuMain) is where the form's title would be if the form wasn't borderless.

        if (this.WindowState == FormWindowState.Normal)
        {
            this.WindowState = FormWindowState.Maximized;
        }
        else if (this.WindowState == FormWindowState.Maximized)
        {
            this.WindowState = FormWindowState.Normal;
        }
    }
1

There are 1 best solutions below

0
On

Just replace the event "MouseDoubleClick" with the event "DoubleClick".