-
July 16th, 2009, 08:37 PM
#1
Enumerating Colours
Does anyone know of a cool way to enumerate all of the members of Color?
So, for example, a routine that would display:
AntiqueWhite [ ]
Aqua [ ]
...
YellowGreen [ ]
Where the contents of the [ ] has a background colour matching the Color member?
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
-
July 17th, 2009, 01:40 AM
#2
Re: Enumerating Colours
How about...
Code:
foreach ( KnownColor name in Enum.GetValues( typeof( KnownColor ) ) )
{
Color c = Color.FromKnownColor( name );
}
Last edited by BigEd781; July 17th, 2009 at 01:43 AM.
-
July 17th, 2009, 02:16 AM
#3
Re: Enumerating Colours
Yep. That's a bit too cool
Thanks
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
-
July 17th, 2009, 07:50 AM
#4
Re: Enumerating Colours
You also have a few more colors defined in the SystemColors for form display colors. I hope that helps.
-
July 17th, 2009, 07:54 AM
#5
Re: Enumerating Colours
You could also use the Enum.GetNames method. You have to remember, with all these types of things ( Enums ), for example, the colours, BorderStyles, StartPosition etc., you have to use the same format to get the containing info
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|