System.Drawing.Color to String

S

shapper

Hello,

How do I convert a property of System.Drawing.Color to a string, i.e.,
"#FFFFFF"?

I have the following but it is not working:
MyColor.ToString

Thanks,
Miguel
 
M

Mark Rae [MVP]

How do I convert a property of System.Drawing.Color to a string, i.e.,
"#FFFFFF"?

I have the following but it is not working:
MyColor.ToString

There may be a built-in way, but I use this:

private string ColorToHex(Color pobjColor)
{
return "#" + string.Format("{0:X2}{1:X2}{2:X2}", pobjColor.R,
pobjColor.G, pobjColor.B).ToLower();
}
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top