Results 1 to 5 of 5

Thread: [2.0] Enumerate the KnownColors

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Question [2.0] Enumerate the KnownColors

    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:
    Code:
    lblColor.BackColor = (Color)KnownColor.Gainsboro;
    [edit]
    I was able to get the BackColor from a KnownColor:
    Code:
    lblColor.BackColor = Color.FromKnownColor(KnownColor.Gainsboro);
    Now I see that the Color enum also contains the members out of KnowColor also.

    But I still don't have a clue how to create a dialog like the VS color picker in the attachment.
    Attached Images Attached Images  
    Last edited by wey97; Oct 23rd, 2006 at 08:49 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width