color

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Trond

    color

    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






  • Ollie Riches

    #2
    Re: color

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


    System.Type colorType = typeof(System.D rawing.Color);
    System.Reflecti on.PropertyInfo[] cpi = colorType.GetPr operties();

    for(int i = 0; i < cpi.Length; i++)
    {
    if(cpi[i].PropertyType == typeof(System.D rawing.Color))
    {
    System.Drawing. Color color =
    (System.Drawing .Color)cpi[i].GetValue(color Type, null);
    Console.WriteLi ne(color.Name + " = " + color.R + "," + color.G + ","
    + color.B);
    }
    }


    --
    HTH

    Ollie Riches


    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.




    "Trond" <trond@montanis .com> wrote in message
    news:upm%23waaS FHA.2860@TK2MSF TNGP10.phx.gbl. ..[color=blue]
    > 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
    >
    >
    >
    >
    >
    >[/color]


    Comment

    Working...