简体   繁体   English

c# 表单最小化/最大化按钮不见了?

[英]c# Form Minimize/Maximize Buttons gone?

On one of my forms the Minimize/Maximize Buttons are gone.在我的 forms 之一上,最小化/最大化按钮不见了。 The ControllBox is set to true as is the MaximizeBox and MinimizeBox . ControllBox设置为trueMaximizeBoxMinimizeBox也是如此。

Is there some other setting I have missed?我错过了其他设置吗?

Check your FormBorderStyle on that form,检查该表单上的FormBorderStyle

FixedToolWindow and SizableToolWindow and None doesn't have those controls at all. FixedToolWindowSizableToolWindowNone根本没有这些控件。

Coming late to the game, I still would like to share my answer as I spent a good couple of hours searching for a fix.游戏迟到了,我仍然想分享我的答案,因为我花了好几个小时寻找修复方法。 My form had all the properties set as they should, but still the minimize/maximize buttons wouldn't show.我的表单已按照应有的方式设置了所有属性,但仍然无法显示最小化/最大化按钮。

The culprit was overriding the CreateParams method from my form, eg罪魁祸首是从我的表单中覆盖CreateParams方法,例如

    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams Params = base.CreateParams;
            Params.ExStyle |= 0x80;
            return Params;
        }
    }

My original intention of overriding this method was to hide my app from the task switcher (alt-tab).我覆盖此方法的初衷是从任务切换器(alt-tab)中隐藏我的应用程序。 I didn't think of this as the reason for not showing the buttons mentioned above, alas, it was.我不认为这是不显示上面提到的按钮的原因,唉,它是。

For further reference, here is the documentation of the flags .为了进一步参考, 这里是 flags 的文档

In my project, the FormBorderStyle was already set to FixedSingle .在我的项目中, FormBorderStyle已经设置为FixedSingle So, I was not sure why the MinimizeBox / MaximizeBox were still not visible.所以,我不确定为什么MinimizeBox / MaximizeBox仍然不可见。 Then, somehow, I managed to find an alternative solution for this.然后,不知何故,我设法为此找到了替代解决方案。


Inside of your C# project, simply press: Ctrl + Shift + F buttons, then search for the MinimizeBox / MaximizeBox variables.在您的 C# 项目中,只需按: Ctrl + Shift + F按钮,然后搜索MinimizeBox / MaximizeBox变量。

I was surprised to find its value set to False at first.一开始我很惊讶地发现它的值设置为False So, to fix, I simply changed the value from False -> True then, problem solved.因此,为了修复,我只是将值从False更改为 -> True然后,问题就解决了。


In my case, since it is an open source project, the author has changed its value.就我而言,由于它是一个开源项目,因此作者更改了它的值。 So, I just need to find those variables using the Find in Files function by Microsoft Visual Studio.因此,我只需要使用 Microsoft Visual Studio 的Find in Files function 来查找这些变量。 It can also be found in the Microsoft Visual Studio's menu bar: Edit -> Find and Replace -> Find in Files .它也可以在 Microsoft Visual Studio 的菜单栏中找到: Edit -> Find and Replace -> Find in Files中查找。
在此处输入图像描述

Hopefully useful for all of you as well!希望对大家也有用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM