Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Asp.Net Programming

Color


Hello,

How can I convert a variable of type color to a String where the color
is in the format #FFFFFF?

Thanks,
Miguel

string htmlColour = "#FFFFFF";
Color transColor = System.Drawing.ColorTranslator.FromHtml(htmlColour);

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog

"shapper" <mdmo@gmail.com> wrote in message

news:1180475569.740612.274840@h2g2000hsg.googlegroups.com...

"shapper" <mdmo@gmail.com> wrote in message

news:1180475569.740612.274840@h2g2000hsg.googlegroups.com...

> How can I convert a variable of type color to a String where the color
> is in the format #FFFFFF?

Not quite sure what you're looking for here - what are you expecting the
string to contain after the conversion...?

--
http://www.markrae.net

-----------------------------------------------Reply-----------------------------------------------

On May 29, 11:18 pm, "Mark Rae" <m@markNOSPAMrae.net> wrote:

> "shapper" <mdmo@gmail.com> wrote in message

> news:1180475569.740612.274840@h2g2000hsg.googlegroups.com...

> > How can I convert a variable of type color to a String where the color
> > is in the format #FFFFFF?

> Not quite sure what you're looking for here - what are you expecting the
> string to contain after the conversion...?

> --http://www.markrae.net

I want to use the string #FFFFFF in a style. So i need the color in
that format.
So if color is white I need to get "#FFFFFF"

Thanks,
Miguel

-----------------------------------------------Reply-----------------------------------------------

I think this is what you want.

 Color color = Color.White;
 string hexFormat= string.Format("#{0:X}", color.ToArgb());
 Console.WriteLine(hexFormat);

//note: written in C#

--Papanii

"shapper" <mdmo@gmail.com> wrote in message

news:1180478026.742404.179850@u30g2000hsc.googlegroups.com...

This function should do the trick:

public static string GetRgbHex(Color c)
{
        return string.Format("{0:x6}", c.ToArgb() & 0xFFFFFF);

}

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net

"shapper" <mdmo@gmail.com> wrote in message

news:1180475569.740612.274840@h2g2000hsg.googlegroups.com...

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc