Hi all,

for a while now I have been trying to figure out how to output a complete list of RGB color values to a combobox but am really stuck as to how to start.

The values need to be sequential starting at (0,0,0) right the way up to (25,255,255) with no duplicates and sorted ascending.

I realise that there are 16.7 million of them but this is what I need.

Any pointers would be appreciated.

Regards..,

I would recommend using a color picker control rather than a combobox, if only for the compactness of the design.

A combobox with 16.7 million entries would be useless. 3 numeric up/down controls would be much better.

If you have to use a combobox, could you explain why?

Hi,

no doesn't have to be a combobox, it could be a listbox or anything really that will list the entire 16.7 + million entries, each oin their own line.

Regards..,

I'm with Momerath here. Just out of curiosity what use could 16.7 million rows be to anyone?
If you need to proceed what you need to do can be done with nested for statements, three of them, each one holding one of the sets of 0 to 255. Then just loop through slowly building up your ascending, really, really long list

I know it's a really, really long list.

I was thinking about using three statements i.e. r, g & b and I know how to individually create a list using them from 0 to 255.

Where I am struggling is knowing how to get them all to work togother so for example:

in the first row; r=0, g=0, b=0

then following that; r=0 b=0, b=1

up until r=0, g=0 & b=255

then after that; r=0, g=1, b=0

then r=0, g=1, b=1

and so on up to r=0, g=1 & b=255

I think everyone can see or knows the sequence

I am sorry if this looks relatively easy to all you pros out there.

The thing is that with my currently limited knowledge all I can achieve is:

r=0, g=0, b=0
r=1, g=1, b=1

and so on to:

r=255, g=255, b=255

So I really need pointers in how to allow just the 'b' to iterate from 0 through to 255 and then increase 'g' by 1, resetting 'b' to zero to start the increments to 255 once again.

Regards..,

Still going to say anything with 16.7 million lines is useless in a user interface. But I guess you'll have to learn that for yourself.

for (int r = 0; r < 256; r++) {
    for (int g = 0; g < 256; g++) {
        for (int b = 0; b < 256; b++) {
            Console.WriteLine("r={0} g={1} b={2}", r, g, b);
        }
    }
}

Once you realize this, no, there isn't anything you can do to speed it up (the UI), you'll have to use a different way to represent the values (color picker, up/down, etc.)

Thanks Momerath, that helps me out a great deal.

I am well renowned for trying to 'flog a dead horse' before actually finding an easier way to achieve the same end.

I only need this function to generate the list once and then I will store it as a text or database file to use in an application that I am thinking of starting.

My idea for an application is more than likely a non-starter but hey, you don't get anything if you don't try.

Much appreciated to all for the help here.

regards..,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.