我正在编写一个带有无边框表单的 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;
}
}
只需将事件“MouseDoubleClick”替换为事件“DoubleClick”即可。