Saturday, June 14, 2008

Setting BackColor to System Colors (like "Control")

It took a little searching to find out how to set the BackColor or ForeColor property of a control to the predefined colors you gets in the Visual Studio Properties window for BackColor's popup color setting on the System tab. For example, I want to set to the BackColor to the "Control" color.

control.BackColor = Color.FromKnownColor(KnownColor.Control)


I found this on:

http://bytes.com/forum/thread654472.html

15 comments:

Anonymous said...

Thanks

Anonymous said...

Excellent thanks

Anonymous said...

In addition to setting the BackColor back to SystemColors.Control, I found that I also had to set UseVisualStyleBackColor to True to have the button again look as it did by default.

Anonymous said...

Been looking for this.
Thanks for the info!

Rajeev said...

Thanks,
It was helpful

Anonymous said...

saved me lots of time...thanks a lot

Anonymous said...

This is great for controls like a Button or CheckBox, but controls like a TextBox or ComboBox will need Color.FromKnownColor(KnownColor.Window) (or SystemColors.Window)
It is better to set the BackColor to Color.Empty or simply use control.ResetBackColor()

Anonymous said...

Thank you very much.

Anonymous said...

Thanks a lot friend

Anonymous said...

Thanks a lot, my friend

ER said...

Thanks. My first hit on that one and got your answer right away!
Try SystemColors.Window which does the same as shorter Term

Anonymous said...

Thanks!

Anonymous said...

Thank you!

Charlie said...

Still thanking!

Anonymous said...

And 8 years later, the thanks are still coming in! :)