Numeric values of Color.....

J

Jack Smith

I am using Image button and its property backcolor = DarkGray.

How to find out the numeric value of this color?

Thanks,

Jack
 
K

Kyle Eberle

I assume by numeric value you mean the RGB values associated with that
color.

The values should then be in the Color.R, Color.G and Color.B byte values.
If you need to convert them to hex you can do something like this:

ImageButton.BackColor.R.ToString("X2");
ImageButton.BackColor.G.ToString("X2");
ImageButton.BackColor.B.ToString("X2");

If you are pulling the color by name you might have to do this:
System.Drawing.Color myColor = System.Drawing.Color.FromName("DarkGray");

Hope that helps,
Kyle
 
K

Karl Seguin

The best way is to use the ColorTranslator:

Color c = ColorTranslator.FromHtml("DarkGray");
Response.Write(c.R);
Response.Write(c.G);
Response.Write(c.B);

which is located in System.Drawing (you'll need to reference that dll).

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top