How can you enumerate an enum?
Ex:
The KnownColor enum is full of known color names like White, Black, Green, Red, Gainsboro, etc. I think it includes Web colors as well as System Colors but that's fine.
What I want to do is give the user an option to pick a Web Color like the Visual Studio Color Selector. I've tried the ColorDialog but it only represents RGB colors.
The next problem is I'm setting the background color of a label to the color the user picked lblColor.BackColor =
but there's no way I know of to convert from a KnowColor to Color.
A cast won't work:
[edit]Code:lblColor.BackColor = (Color)KnownColor.Gainsboro;
I was able to get the BackColor from a KnownColor:
Now I see that the Color enum also contains the members out of KnowColor also.Code:lblColor.BackColor = Color.FromKnownColor(KnownColor.Gainsboro);
But I still don't have a clue how to create a dialog like the VS color picker in the attachment.




Reply With Quote