A
A
Alexander2014-07-21 18:59:26
C++ / C#
Alexander, 2014-07-21 18:59:26

How to convert system color name to color value in C#?

There is a string with the name of the system color, for example - BtnFace, how to get the value of System.Drawing.SystemColors.ButtonFace ?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
AlexP11223, 2014-07-21
@OneFive

.ToArgb()? Well, or there are properties R, G and B, as well as A, with the corresponding values.
And what is the goal? Why is this?

A
Alexander Taratin, 2014-07-21
@Taraflex

vk.cc/2O8D22

S
Sumor, 2014-07-22
@Sumor

System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml("Red");

or
If you need to get Color for Wpf, then you can do something like this:
System.Drawing.Color wfColor = System.Drawing.Color.FromName("Red");
System.Windows.Media.Color color = System.Windows.Media.Color.FromArgb(wfColor.A,wfColor.R,wfColor.G,wfColor.B );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question