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
110
How do you customize the color palette in a color picker?
posted

Hey,

In the page for the color picker found at https://www.infragistics.com/products/windows-forms/data-entry-and-display/color-picker, there's a section on "Customize your Palette".

How do you change those colors? I do not want to add/change/remove what you call custom colors (for which methods in the UltraPaletteInfo do exist), but rather a number of colors in the grid itself. I've found the UltraPaletteInfo has Row and Column properties (which you can add to), but neither of those two have an option to actually add colors.

So eventually, I would like to change my color palette to either of those programmatically.

https://static.infragistics.com/marketing/Website/products/windows-forms/controls/data-entry-and-display/color-picker/color-picker-palettes.png?v=201803200900

Thanks in advance!

  • 12465
    Verified Answer
    Offline posted

    Hi Uwe,

    You can customize the palette by indexing each row object in the PaletteInfo. I've attached a sample here that demonstrates how to work with palettes by generating a new palette and setting that palette to the Color Picker.

    For reference, here is the relevant code:

    private void RandomizePalette()
    {
        UltraPaletteInfo palette = new UltraPaletteInfo();
        int numRows = random.Next(5, 15);
        int numColumns = random.Next(5, 10);
    
        for (int i = 0; i < numColumns; i++)
        {
            palette.Columns.Add();
        }
    
        for (int i = 0; i < numRows; i++)
        {
            GridPaletteRow row = palette.Rows.Add();
            for (int j = 0; j < numColumns; j++)
            {
                row[j] = Color.FromArgb(random.Next(256), random.Next(256), random.Next(256));
            }
        }
    
        ultraColorPicker1.PaletteInfo = palette;
    }
    

    Please look over the sample and let me know if this answers your question.

    UltraColorPickerCustomPalette.zip