convert

  • Thread starter Thread starter Ion Lenta
  • Start date Start date
I

Ion Lenta

Hi,

I have in database a colomn "color". In this colomn colors are saved in
hex format. Now, I have to use this format for windows BackColor.

1. Can I use this format directly without some convertions?
2. If no, how can I convert (add) it to RGB format?

Thanks a lot,
Ion.
 
Hi Ion,
1. Can I use this format directly without some convertions?

Don't think so.
2. If no, how can I convert (add) it to RGB format?

Well, first you need to add an alpha value to the hex value.

string s = "ff00ff"; // original hex value
s = "ff" + s; // add an alpha value

Color c = Color.FromArgb(Int32.Parse(s, NumberStyles.HexNumber));

That should first convert it to an int which in turn is converted to rgb.
NumberStyles is found in System.Globalization.
 
Back
Top