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

C#WinformsColors

C# Problem Overview


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.

C# Solutions


Solution 1 - C#

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

this.BackColor = SystemColors.Control;

The full range of properties to access other colours is listed on http://msdn.microsoft.com/en-us/library/system.drawing.systemcolors_members.aspx">MSDN</a>;.

Solution 2 - C#

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

this.BackColor = Control.DefaultBackColor;

Solution 3 - C#

this.BackColor = default(Color);

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

Solution 4 - C#

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

this.BackColor = Color.Transparent;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSergio TapiaView Question on Stackoverflow
Solution 1 - C#stevemegsonView Answer on Stackoverflow
Solution 2 - C#pyrocumulusView Answer on Stackoverflow
Solution 3 - C#SparfyView Answer on Stackoverflow
Solution 4 - C#daniele3004View Answer on Stackoverflow