color

T

Trond

Is there a way i can print out every color in System.Drawing.Color ?

I tried with foreach ( Color c in Color)

but that ain't working. I was thinking that it would be nice to see the
colors in a listbox.

So i am a lil stuck and any hint would help a lot

Best regards

Trond
 
O

Ollie Riches

probably an easier way than this but you could use reflection:


System.Type colorType = typeof(System.Drawing.Color);
System.Reflection.PropertyInfo[] cpi = colorType.GetProperties();

for(int i = 0; i < cpi.Length; i++)
{
if(cpi.PropertyType == typeof(System.Drawing.Color))
{
System.Drawing.Color color =
(System.Drawing.Color)cpi.GetValue(colorType, null);
Console.WriteLine(color.Name + " = " + color.R + "," + color.G + ","
+ color.B);
}
}


--
HTH

Ollie Riches
http://www.phoneanalyser.net

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top