【问题标题】:How can I change the color of all my forms from just one of my forms?我怎样才能从我的一个表格中更改我所有表格的颜色?
【发布时间】:2014-09-07 22:39:45
【问题描述】:

我试过了:

//this code is triggered when i click a button on the form(lets call it form3)
// the first line works, but the second line is ReadOnly
this.BackColor = System.Drawing.Color.Crimson;
DefaultBackColor = this.BackColor;

在 form1 上,我有一个带有以下代码的按钮,没有 cmets,当我单击它时触发:

//this button is basically a refresh button for the background
this.BackColor = form3.DefaultBackColor;

我是 stackoverflow 的新手,因此非常感谢您的帮助,特别是如果可以提供替代代码。 :)

【问题讨论】:

    标签: c# forms colors customization


    【解决方案1】:

    也许这有用?:Application.OpenForms

    您可以遍历集合并以这种方式设置表单颜色。

    【讨论】:

      【解决方案2】:

      您可以创建一个获取和设置表单颜色的类。

      当用户更改颜色时,全局变量将更改为(取决于处理方式)可能是十六进制颜色值。每当调用另一个表单时,只需获取设置的值。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-10-25
        • 2017-07-12
        • 2023-02-06
        • 2012-08-13
        • 2015-06-16
        • 2021-06-22
        • 2014-05-14
        • 2019-04-09
        相关资源
        最近更新 更多