how to convert color in style "#e6e6e6" to color object in vb.net

Discussion in 'ASP .Net' started by moondaddy, Apr 27, 2004.

  1. moondaddy

    moondaddy Guest

    I have a color I want to set via code. the color from the style is
    "#e6e6e6". The only property I saw that came close to what I need is
    color.fromAargb(). How can I translate this color into something .net can
    use.




    --
     
    moondaddy, Apr 27, 2004
    #1
    1. Advertising

  2. moondaddy

    Matt Berther Guest

    Hello moondaddy,

    > I have a color I want to set via code. the color from the style is
    > "#e6e6e6". The only property I saw that came close to what I need is
    > color.fromAargb(). How can I translate this color into something .net
    > can use.
    >


    Try Color.FromArgb(0xe6e6e6);

    --
    Matt Berther
    http://www.mattberther.com
     
    Matt Berther, Apr 27, 2004
    #2
    1. Advertising

  3. Hi Moondaddy,

    From your description, you'd like to convert the web color's string hex
    value(string) into a System.Drawing.Color class's instance, yes?

    In think the System.Drawing.ColorTranslator class is the one you want, it
    has a member function called "FromHtml" which can help translate a web
    color's string hex value into a Color instance, for example:

    Color clr = ColorTranslator.FromHtml("#0000FF");
    will return a color instance(clr) which represent the following color:
    Color [A=255, R=0, G=0, B=255]

    In addtion, below is the ColorTranslator class's document in MSDN:

    #ColorTranslator Class
    http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdrawingcolortr
    anslatorclasstopic.asp?frame=true

    #ColorTranslator.FromHtml Method
    http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDrawingColorTr
    anslatorClassFromHtmlTopic.asp?frame=true

    Hope helps. Thanks.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
     
    Steven Cheng[MSFT], Apr 28, 2004
    #3
  4. moondaddy

    moondaddy Guest

    Thanks Matt and Steven. the colorTranslator did it for me.

    --

    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Moondaddy,
    >
    > From your description, you'd like to convert the web color's string hex
    > value(string) into a System.Drawing.Color class's instance, yes?
    >
    > In think the System.Drawing.ColorTranslator class is the one you want, it
    > has a member function called "FromHtml" which can help translate a web
    > color's string hex value into a Color instance, for example:
    >
    > Color clr = ColorTranslator.FromHtml("#0000FF");
    > will return a color instance(clr) which represent the following color:
    > Color [A=255, R=0, G=0, B=255]
    >
    > In addtion, below is the ColorTranslator class's document in MSDN:
    >
    > #ColorTranslator Class
    >

    http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdrawingcolortr
    > anslatorclasstopic.asp?frame=true
    >
    > #ColorTranslator.FromHtml Method
    >

    http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDrawingColorTr
    > anslatorClassFromHtmlTopic.asp?frame=true
    >
    > Hope helps. Thanks.
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    > Get Preview at ASP.NET whidbey
    > http://msdn.microsoft.com/asp.net/whidbey/default.aspx
    >
     
    moondaddy, Apr 28, 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. Noah
    Replies:
    5
    Views:
    787
  2. Replies:
    5
    Views:
    1,934
    Wesley Hall
    Nov 4, 2006
  3. Ken Varn
    Replies:
    0
    Views:
    471
    Ken Varn
    Apr 26, 2004
  4. Kamaljeet Saini
    Replies:
    0
    Views:
    427
    Kamaljeet Saini
    Feb 13, 2009
  5. Jake Barnes
    Replies:
    6
    Views:
    198
    Lawrence Krubner
    Apr 12, 2009
Loading...

Share This Page