How to load a combobox with web colours

J Trahair

Well-known member
Joined
May 14, 2008
Messages
175
Location
Spain
Programming Experience
10+
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.
 
VB.NET:
        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
 
Back
Top