Results 1 to 5 of 5

Thread: Hex Colours in .net ??? (Sorted)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    Outer space
    Posts
    97

    Hex Colours in .net ??? (Sorted)

    i need to set the colour of a menu to this style but when i create the style it needs to be in .net not in a style sheet as they are generated @ runtime ... but how do i add hex values in vb.net ?

    the following don't work

    MyStyle.BackColor = Color.FromName()
    MyStyle.BackColor = Color.FromArgb()
    MyStyle.BackColor = Color.FromKnownColor

    do i need to setup a colour object ??

    many thanks
    john
    Last edited by OptimusPrime; Jun 30th, 2003 at 09:26 AM.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    Outer space
    Posts
    97
    i tried the colour object thing but couldn't add a hex value ... it needs to be set to #003366 btw

  3. #3
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245
    The easiest thing would probably be to convert your hex value to an RGB value and then use the Color.FromARGB function. This link is to an example in VB. It shouldn't be hard to convert it to VB.NET.
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    Outer space
    Posts
    97
    just sorted it .... 2 secs and ill post up what i did

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    Outer space
    Posts
    97
    PHP Code:
    Dim MyColourTranslator As ColorTranslator
    MyStyle
    .BackColor MyColourTranslator.FromHtml("#003366"

    which works fine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width