+ Reply to Thread
Results 1 to 3 of 3

Thread: How to load a combobox with web colours

  1. #1
    J Trahair is offline VB.NET Forum Enthusiast J Trahair is on a distinguished programming path ahead
    .NET Framework
    .NET 3.0 (VS 2005/2008)
    Join Date
    May 2008
    Location
    Spain
    Posts
    90
    Reputation
    32

    Default How to load a combobox with web colours

    I want to load a combobox with the web colours - eg. WhiteSmoke, Gainsboro, NavajoWhite.

    I know there is a ColorDialog, which has a smaller range of brighter colours. Don't want that. I also know how to fill a combobox with something.

    How can I get a list of these colours?

    Thanks in advance.

  2. #2
    InertiaM is offline VB.NET Forum Idol InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame
    .NET Framework
    .NET 2.0
    Join Date
    Nov 2007
    Location
    Kent, UK
    Age
    40
    Posts
    567
    Reputation
    176

    Default

    Code:
            Dim colorNames As String() = [Enum].GetNames(GetType(KnownColor))
            For Each colorName As String In colorNames
                Dim _knownColor As KnownColor = DirectCast([Enum].Parse(GetType(KnownColor), colorName), KnownColor)
                If _knownColor > KnownColor.Transparent AndAlso _knownColor < KnownColor.ButtonFace Then
                    ComboBox1.Items.Add(colorName)
                End If
            Next
    Always parameterize your queries - read more here

    "When people discover the center of the universe, a lot of them will be disappointed to find they are not it."

  3. #3
    J Trahair is offline VB.NET Forum Enthusiast J Trahair is on a distinguished programming path ahead
    .NET Framework
    .NET 3.0 (VS 2005/2008)
    Join Date
    May 2008
    Location
    Spain
    Posts
    90
    Reputation
    32

    Default

    Thank you - just what I needed.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

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