Convert string to KnownColor?

  • Thread starter Thread starter mianiro
  • Start date Start date
M

mianiro

I have a piece of code that is trying to convert a string to a
knownColor via CType. Is this not possible? I keep getting an error
that you cant convert a string to an integer. Is there another way to
do this?

For Each clr as object In Colors
If Not Color.FromKnownColor(CType(clr,
KnownColor)).IsSystemColor Then
alColor.Add(clr.ToString)
End If
Next


Thanks so much.
 
Yes, Enum.Parse();

-----------------------------------------v
Giving sample for someone to use in future.

KnownColor kc=(KnownColor) Enum.Parse(typeof(KnownColor), "White", true);



mianiro wrote:

Convert string to KnownColor?
05-Apr-07

I have a piece of code that is trying to convert a string to
knownColor via CType. Is this not possible? I keep getting an erro
that you cant convert a string to an integer. Is there another way t
do this

For Each clr as object In Color
If Not Color.FromKnownColor(CType(clr
KnownColor)).IsSystemColor The
alColor.Add(clr.ToString
End I
Nex

Thanks so much.

Previous Posts In This Thread:

Convert string to KnownColor?
I have a piece of code that is trying to convert a string to
knownColor via CType. Is this not possible? I keep getting an erro
that you cant convert a string to an integer. Is there another way t
do this

For Each clr as object In Color
If Not Color.FromKnownColor(CType(clr
KnownColor)).IsSystemColor The
alColor.Add(clr.ToString
End I
Nex

Thanks so much.

Re: Convert string to KnownColor?
System.Enum.Pars

Mattia

-
Mattias Sj?gren [C# MVP] mattias @ mvps.or
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.co
Please reply only to the newsgroup.

Re: Convert string to KnownColor?
wrote
net/|http://www.dotnetinterop.co

Thank you so much!

EggHeadCafe - Software Developer Portal of Choice
Sum of Numbers Captcha: Keeping it Simple
http://www.eggheadcafe.com/tutorial...83-8eb1c526ca7f/sum-of-numbers-captcha-k.aspx
 
Back
Top