Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3045
How do you make ColorPicker display Name equivalent of RGB value during assignment?
posted

I'm using FromArgb() to create the Color object that I use to assign to the Color property of the ColorPicker. It selects the correct color but it display the RGB value even for named colors on initial assignment. It does change the display to the Name once you leave (TAB or click something else) the ColorPicker control. 

  • 469350
    Verified Answer
    Offline posted

    Hi,

    So you want the control to display the named color when you set it?

    What's probably happening is that when you create a color using FromArgb, you are creating a color that is not a named color. The DotNet Framework doesn't automatically check to see if the color is a named color and return it to you, it just gives you a color with the Argb values you specified.

    The UltraColorPicker, on the other hand, attempts to take the text that the user enters and match it up to a named color whenever possible. So once you lose focus on the control, it's processing the text in the control and finding a match in the named colors, if there is one.

    If you want the color name to show up initially, then you could do the same thing the control does and try to get the color from a string. The method by which is does this is a public static method on the ColorPickerEditor class:


                Color color = Color.FromArgb(255, 0, 0);
                color = Infragistics.Win.ColorPickerEditor.ColorFromString("255, 0, 0", color, true);
                this.ultraColorPicker1.Color = color;