Hi Roger,
You should be able to get all of the colors (including system colors) like
this:
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
If Not IsPostBack Then
Dim strSelectedColor As String
Dim enumColor As New KnownColor
Dim Colors As Array = _
[Enum].GetValues(enumColor.GetType())
DropDownList1.DataSource = Colors
DropDownList1.DataBind()
strSelectedColor = DropDownList1.Items(0).Text
End If
End Sub 'Page_Load
Private Sub DropDownList1_SelectedIndexChanged _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles DropDownList1.SelectedIndexChanged
Label1.Text = DropDownList1.SelectedItem.Text
End Sub
<form id="Form1" method="post" runat="server">
<P>
<asp
ropDownList id="DropDownList1" runat="server"
AutoPostBack="True"></asp
ropDownList></P>
<P>
<asp:Label id="Label1" runat="server"></asp:Label></P>
</form>
Ken
MVP [ASP.NET]
Roger said:
Hi,
I'm trying to populate an array with color names. I keep getting an
error.
Here is the line that fails:
Dim Colors As String() = Enum.GetValues(enumColor.GetType())