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?
Printable View
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?
How about...
Code:foreach ( KnownColor name in Enum.GetValues( typeof( KnownColor ) ) )
{
Color c = Color.FromKnownColor( name );
}
Yep. That's a bit too cool ;)
Thanks
You also have a few more colors defined in the SystemColors for form display colors. I hope that helps.
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 :)