Home All Groups Group Topic Archive Search About

Convert string to KnownColor?

Author
5 Apr 2007 8:12 PM
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.

Author
5 Apr 2007 9:40 PM
Mattias Sjögren
>Is there another way to do this?

System.Enum.Parse


Mattias

--
Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Author
6 Apr 2007 11:38 AM
mianiro
On Apr 5, 5:40 pm, Mattias Sjögren <mattias.dont.want.s***@mvps.org>
wrote:
> >Is there another way to do this?
>
> System.Enum.Parse
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP]  mattias @ mvps.orghttp://www.msjogren.net/dotnet/|http://www.dotnetinterop.com
> Please reply only to the newsgroup.

Thank you so much!

AddThis Social Bookmark Button