C# 如何调用控件颜色,我的意思是默认表单颜色?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1600787/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 19:15:36  来源:igfitidea点击:

How can I call the Control color, I mean the default forms color?

c#winformscolors

提问by Sergio Tapia

For instance, to make something blue I would go:

例如,要制作蓝色的东西,我会去:

this.BackColor = Color.LightBlue;

How can I summon the Control color, the khaki one.

我怎样才能召唤出控制色,卡其色。

Thanks SO.

谢谢。

采纳答案by stevemegson

The System.Drawing.SystemColorsclass has properties exposing the various system colours, so you can do

System.Drawing.SystemColors类具有暴露的各种系统颜色,所以你可以做

this.BackColor = SystemColors.Control;

The full range of properties to access other colours is listed on MSDN.

MSDN上列出了访问其他颜色的所有属性。

回答by pyrocumulus

I haven't tested this, but I believe it to be:

我没有测试过这个,但我相信它是:

this.BackColor = Control.DefaultBackColor;

回答by Sparfy

this.BackColor = default(Color);

Seems to be the color that the form designer uses...

好像是表单设计者使用的颜色...

回答by daniele3004

Another way for example is to use the Transaperntto set the color of control Parent

另一种方法例如是使用Transapernt来设置控件的颜色Parent

this.BackColor = Color.Transparent;