【问题标题】:Disabled buttons on dark background are not shown properly深色背景上的禁用按钮未正确显示
【发布时间】:2018-08-21 18:37:16
【问题描述】:

我在面板上有一些深色背景的按钮。通常,当面板被禁用时,Label 上的文本以及 Button 上的文本都是灰色的,因此用户可以看到它们被禁用。但是当 Panel 设置了深色背景时,灰色的颜色会有所不同,并且禁用的按钮看起来与启用的按钮过于相似。仅当 Button 将 UseVisualStyleBackColor 设置为 true 时才会发生这种情况。

我可以做些什么来让用户看到按钮被禁用? (假设我想要深色背景和 UseVisualStyleBackColor)

【问题讨论】:

    标签: c# winforms


    【解决方案1】:

    你有两个选择:

    在你的表单中 load 事件集

    SomeButton.BackColor = SystemColors.Control;
    SomeButton.UseVisualStyleBackColor = true;
    

    或在设计器中手动将上述属性设置为按钮

    【讨论】:

    • 谢谢,效果很好!但它需要按此顺序完成,因为设置 BackColor 会自动将 UseVisualStyleBackColor 设置为 false。我还注意到,默认情况下,当按钮添加到 Panel 时,它的 BackColor 设置为与 Panel 相同的值,这就是它显示不同的原因。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-04
    • 1970-01-01
    • 1970-01-01
    • 2023-02-13
    • 1970-01-01
    • 1970-01-01
    • 2014-12-25
    相关资源
    最近更新 更多