Numeric values of Color.....

Discussion in 'ASP .Net' started by Jack Smith, Nov 5, 2004.

  1. Jack Smith

    Jack Smith Guest

    I am using Image button and its property backcolor = DarkGray.

    How to find out the numeric value of this color?

    Thanks,

    Jack
     
    Jack Smith, Nov 5, 2004
    #1
    1. Advertising

  2. Jack Smith

    Kyle Eberle Guest

    I assume by numeric value you mean the RGB values associated with that
    color.

    The values should then be in the Color.R, Color.G and Color.B byte values.
    If you need to convert them to hex you can do something like this:

    ImageButton.BackColor.R.ToString("X2");
    ImageButton.BackColor.G.ToString("X2");
    ImageButton.BackColor.B.ToString("X2");

    If you are pulling the color by name you might have to do this:
    System.Drawing.Color myColor = System.Drawing.Color.FromName("DarkGray");

    Hope that helps,
    Kyle



    "Jack Smith" <> wrote in message
    news:#...
    > I am using Image button and its property backcolor = DarkGray.
    >
    > How to find out the numeric value of this color?
    >
    > Thanks,
    >
    > Jack
    >
    >
     
    Kyle Eberle, Nov 6, 2004
    #2
    1. Advertising

  3. Jack Smith

    bruce barker Guest

    bruce barker, Nov 6, 2004
    #3
  4. Jack Smith

    Karl Seguin Guest

    The best way is to use the ColorTranslator:

    Color c = ColorTranslator.FromHtml("DarkGray");
    Response.Write(c.R);
    Response.Write(c.G);
    Response.Write(c.B);

    which is located in System.Drawing (you'll need to reference that dll).

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Jack Smith" <> wrote in message
    news:%...
    > I am using Image button and its property backcolor = DarkGray.
    >
    > How to find out the numeric value of this color?
    >
    > Thanks,
    >
    > Jack
    >
    >
     
    Karl Seguin, Nov 6, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. moondaddy
    Replies:
    3
    Views:
    38,958
    moondaddy
    Apr 28, 2004
  2. Replies:
    5
    Views:
    981
    X-Centric
    Jun 30, 2005
  3. darrel
    Replies:
    4
    Views:
    868
    darrel
    Jul 19, 2007
  4. jobs

    int to numeric numeric(18,2) ?

    jobs, Jul 21, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    1,017
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jul 22, 2007
  5. Kamaljeet Saini
    Replies:
    0
    Views:
    483
    Kamaljeet Saini
    Feb 13, 2009
Loading...

Share This Page