如何双击无边框表单来调整其大小?

问题描述 投票:0回答:1

我正在编写一个带有无边框表单的 WinForms 应用程序。在常规形式中,您可以双击标题栏以在最大化和正常之间切换其 WindowState。我怎样才能用无边框表单做到这一点?

这是我的菜单 MouseDoubleClick 事件处理程序的代码...

        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;
        }
    }
c# winforms double-click borderless
1个回答
0
投票

只需将事件“MouseDoubleClick”替换为事件“DoubleClick”即可。

© www.soinside.com 2019 - 2024. All rights reserved.