?
Solved

Color.Name return the name not fffetc.

Posted on 2009-04-07
5
Medium Priority
?
205 Views
Last Modified: 2012-05-06
I am using the color dialog to assign a color and the color name to a text box.
Unfortunetly the Color.Name will sometimes bring back the alpha/numeric version instead of the actual name, like the constants.
Users will not want to see the color symbols, only the color name, like light yellow, etc.
How do I get the actual name of the color?
Please provide an example.  I can't click on links without my IE crashing.
Thanks
0
Comment
Question by:Sheritlw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 24091392
Hi Sheritlw,

You can show this way
        Dim c As New ColorDialog
        c.ShowDialog()
        Debug.WriteLine(c.Color.Name.ToString)

Open in new window

0
 

Author Comment

by:Sheritlw
ID: 24091555
Hi jpaulino,

Unfortunetly that doesn't work.   I tried that and on a few colors it will return the name, but on the majority it doesn't.
This is the code I use
 Dim c As New ColorDialog
        c.AllowFullOpen = True
        c.AnyColor = True
        c.SolidColorOnly = True

        c.ShowHelp = True
        If c.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Me.txtCarColor.BackColor = c.Color
            Me.txtCarColor.Text = c.Color.Name.ToString
        End If
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 2000 total points
ID: 24091849
Not all colors have names :)
You can check if the name IsNamedColor before show that information

 Dim c As New ColorDialog
        c.AllowFullOpen = True
        c.AnyColor = True
        c.SolidColorOnly = True
 
        c.ShowHelp = True
        If c.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Me.txtCarColor.BackColor = c.Color
            If c.Color.IsNamedColor Then
                 Me.txtCarColor.Text = c.Color.Name.ToString
            End IF
        End If

Open in new window

0
 

Author Comment

by:Sheritlw
ID: 24092680
I really need to have a name in the text box.  Is there anyway to retrieve the constant name, or maybe just show colors that have a constant assigned?
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24094547
With that picker I don't think you can, but maybe you can create or use a picker that only use namedcolors like this one: http://www.codeproject.com/KB/combobox/ColorComboBox.aspx
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question