Hi,
Has anyone tried the source code on http://www.c-sharpcorner.com/Code/2003/July/DropDownListBox.asp
?
I used the following code but the dropdownlist doesn't show the colors only the color names. What could be the reason?
Thanks
VB.NET
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Dim col As FieldInfo
For Each col In GetType(KnownColor).GetFields
If col.FieldType Is GetType(Drawing.KnownColor) Then
DropDownList1.Items.Add(New ListItem(col.Name, col.Name))
End If
Next
End If
Dim i As Integer
For i = 0 To DropDownList1.Items.Count - 1
DropDownList1.Items(i).Attributes.Add("style", "background-color:" + DropDownList1.Items(i).Text)
Next
End Sub