.NETGURU
SV: Re: hexadecimal to color
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-drawing' list.


=?iso-8859-1?Q?Andr=E9_Colbi=F6rnsen?=
That strikes me as odd, I just tested the following, and it works like a
breeze:

label1.Backcolor =3D Color.FromName("#0000cd")

Are you importing the 'System.Drawing' namespace?

Regards/Halsningar

Andre Colbiornsen
--------------------------------------
Sonnenburg Communications
Bergsgatan 3,
SE-211 54 Malm=F6
Sweden
Tel.: +46-(0)40-97 78 80
Fax.: +46-(0)40-97 78 80
Mob.: +46-(0)708-97 78 79
Mail: Click here to reveal e-mail address
Web.: www.sonnenburg.se
----------------------------------------
B2B Web Solutions - Specializing in .Net
----------------------------------------

-----Ursprungligt meddelande-----
Fr=E5n: Yannick Smits [mailto:Click here to reveal e-mail address]=20
Skickat: den 12 augusti 2002 14:08
Till: ngfx-drawing
=C4mne: [ngfx-drawing] Re: hexadecimal to color

I tried both
Color.FromName("#6B696B") and ColorTranslator.FromHtml("#b5ccff");
but both fail to work. They only work when using a named color like
"Red" not for hexadecimal naming.

Thanks,
Yannick Smits

"Andr=E9 Colbi=F6rnsen" <Click here to reveal e-mail address> wrote in message
news:696486@ngfx-drawing...

Like this (Both VB and C#):

Color.FromName("#6B696B")

Hth

Regards/Halsningar

Andre Colbiornsen
--------------------------------------
Sonnenburg Communications
Bergsgatan 3,
SE-211 54 Malm=F6
Sweden
Tel.: +46-(0)40-97 78 80
Fax.: +46-(0)40-97 78 80
Mob.: +46-(0)708-97 78 79
Mail: Click here to reveal e-mail address
Web.: www.sonnenburg.se
----------------------------------------
B2B Web Solutions - Specializing in .Net
----------------------------------------

-----Ursprungligt meddelande-----
Fr=E5n: Yannick Smits [mailto:Click here to reveal e-mail address]
Skickat: den 12 augusti 2002 04:52
Till: ngfx-drawing
=C4mne: [ngfx-drawing] hexadecimal to color

How can I convert a hexadecimal colorcode (ie #b5ccff) to a
System.Drawing.Color object (C#)?

Thanks,
Yannick Smits

| [ngfx-drawing] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.aspfriends.com/aspfriends/ngfx-drawing.asp =3D JOIN/QUIT

| [ngfx-drawing] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.aspfriends.com/aspfriends/ngfx-drawing.asp =3D JOIN/QUIT

Reply to this message...
 
    
=?iso-8859-1?Q?Andr=E9_Colbi=F6rnsen?=
'True, Color.FromName only works with named colors' This is incorrect,
unless it is specific for C#. I use=20
Color.FromName with hexcode strings all the time in VB.Net and it works
just fine. Someone better clarify this.

Regards/Halsningar

Andre Colbiornsen
--------------------------------------
Sonnenburg Communications
Bergsgatan 3,
SE-211 54 Malm=F6
Sweden
Tel.: +46-(0)40-97 78 80
Fax.: +46-(0)40-97 78 80
Mob.: +46-(0)708-97 78 79
Mail: Click here to reveal e-mail address
Web.: www.sonnenburg.se
----------------------------------------
B2B Web Solutions - Specializing in .Net
----------------------------------------
-----Ursprungligt meddelande-----
Fr=E5n: Shan Nunez, Eduardo [mailto:Click here to reveal e-mail address]=20
Skickat: den 12 augusti 2002 14:28
Till: ngfx-drawing
=C4mne: [ngfx-drawing] Re: hexadecimal to color

    True, Color.FromName only works with named colors, but I have
used ColorTranslator.FromHTML frequently in C#
    and it works fine enough, what sort of error do you get when you
use it?
    Anyway, you could try this workaround: convert the html color
string
to an hexadecimal value ("#ffffff" -> 0xfffffff).     Then you get its
RGB
components (i.e using shifting operators) and create the color    with
Color.FromARGB(int r, int g,=20
    int b).

    Hope this will help.

            Ed.

-----Original Message-----
From: Yannick Smits [mailto:Click here to reveal e-mail address]
Sent: lunes, 12 de agosto de 2002 14:08
To: ngfx-drawing
Subject: [ngfx-drawing] Re: hexadecimal to color

I tried both
Color.FromName("#6B696B") and ColorTranslator.FromHtml("#b5ccff");
but both fail to work. They only work when using a named color like
"Red" not for hexadecimal naming.

Thanks,
Yannick Smits

"Andr=E9 Colbi=F6rnsen" <Click here to reveal e-mail address> wrote in message
news:696486@ngfx-drawing...

Like this (Both VB and C#):

Color.FromName("#6B696B")

Hth

Regards/Halsningar

Andre Colbiornsen
--------------------------------------
Sonnenburg Communications
Bergsgatan 3,
SE-211 54 Malm=F6
Sweden
Tel.: +46-(0)40-97 78 80
Fax.: +46-(0)40-97 78 80
Mob.: +46-(0)708-97 78 79
Mail: Click here to reveal e-mail address
Web.: www.sonnenburg.se
----------------------------------------
B2B Web Solutions - Specializing in .Net
----------------------------------------

-----Ursprungligt meddelande-----
Fr=E5n: Yannick Smits [mailto:Click here to reveal e-mail address]
Skickat: den 12 augusti 2002 04:52
Till: ngfx-drawing
=C4mne: [ngfx-drawing] hexadecimal to color

How can I convert a hexadecimal colorcode (ie #b5ccff) to a
System.Drawing.Color object (C#)?

Thanks,
Yannick Smits

| [ngfx-drawing] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.aspfriends.com/aspfriends/ngfx-drawing.asp =3D JOIN/QUIT

| [ngfx-drawing] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.aspfriends.com/aspfriends/ngfx-drawing.asp =3D JOIN/QUIT

| [ngfx-drawing] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.aspfriends.com/aspfriends/ngfx-drawing.asp =3D JOIN/QUIT

Reply to this message...
 
    
=?iso-8859-1?Q?Andr=E9_Colbi=F6rnsen?=
You obviously do not believe what I say that Color.FromName("HexSTring")
can be used straight out ;). Check it out here then and see for
yourself:

http://213.67.33.162/slask/colorfromname.aspx

Have fun!

Regards/Halsningar

Andre Colbiornsen
--------------------------------------
Sonnenburg Communications
Bergsgatan 3,
SE-211 54 Malm=F6
Sweden
Tel.: +46-(0)40-97 78 80
Fax.: +46-(0)40-97 78 80
Mob.: +46-(0)708-97 78 79
Mail: Click here to reveal e-mail address
Web.: www.sonnenburg.se
----------------------------------------
B2B Web Solutions - Specializing in .Net
----------------------------------------

-----Ursprungligt meddelande-----
Fr=E5n: Shan Nunez, Eduardo [mailto:Click here to reveal e-mail address]=20
Skickat: den 12 augusti 2002 14:28
Till: ngfx-drawing
=C4mne: [ngfx-drawing] Re: hexadecimal to color

    True, Color.FromName only works with named colors, but I have
used ColorTranslator.FromHTML frequently in C#
    and it works fine enough, what sort of error do you get when you
use it?
    Anyway, you could try this workaround: convert the html color
string
to an hexadecimal value ("#ffffff" -> 0xfffffff).     Then you get its
RGB
components (i.e using shifting operators) and create the color    with
Color.FromARGB(int r, int g,=20
    int b).

    Hope this will help.

            Ed.

-----Original Message-----
From: Yannick Smits [mailto:Click here to reveal e-mail address]
Sent: lunes, 12 de agosto de 2002 14:08
To: ngfx-drawing
Subject: [ngfx-drawing] Re: hexadecimal to color

I tried both
Color.FromName("#6B696B") and ColorTranslator.FromHtml("#b5ccff");
but both fail to work. They only work when using a named color like
"Red" not for hexadecimal naming.

Thanks,
Yannick Smits

"Andr=E9 Colbi=F6rnsen" <Click here to reveal e-mail address> wrote in message
news:696486@ngfx-drawing...

Like this (Both VB and C#):

Color.FromName("#6B696B")

Hth

Regards/Halsningar

Andre Colbiornsen
--------------------------------------
Sonnenburg Communications
Bergsgatan 3,
SE-211 54 Malm=F6
Sweden
Tel.: +46-(0)40-97 78 80
Fax.: +46-(0)40-97 78 80
Mob.: +46-(0)708-97 78 79
Mail: Click here to reveal e-mail address
Web.: www.sonnenburg.se
----------------------------------------
B2B Web Solutions - Specializing in .Net
----------------------------------------

-----Ursprungligt meddelande-----
Fr=E5n: Yannick Smits [mailto:Click here to reveal e-mail address]
Skickat: den 12 augusti 2002 04:52
Till: ngfx-drawing
=C4mne: [ngfx-drawing] hexadecimal to color

How can I convert a hexadecimal colorcode (ie #b5ccff) to a
System.Drawing.Color object (C#)?

Thanks,
Yannick Smits

| [ngfx-drawing] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.aspfriends.com/aspfriends/ngfx-drawing.asp =3D JOIN/QUIT

| [ngfx-drawing] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.aspfriends.com/aspfriends/ngfx-drawing.asp =3D JOIN/QUIT

| [ngfx-drawing] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.aspfriends.com/aspfriends/ngfx-drawing.asp =3D JOIN/QUIT

Reply to this message...
 
 
System.Drawing.Color
System.Drawing.ColorTranslator




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification