You can add an Enumeration to a cbo or listbox.
This enumeration lists the known colors in the System.Drawing namespace.
Public Enum KnownColor
'air code:
==========================================
'use an Enum in a cbo:
Dim colorsEnum As Type = GetType(KnownColor)
Dim mColor As String
For Each mColor In [Enum].GetNames(colorsEnum)
Me.cboColors.Items.Add(mColor)
Next mColor
==========================================
'Use an Enum in a listbox
Dim colorsEnum As Type = GetType(Colors)
Dim mColor As String
Dim alColors As New ArrayList
For Each mColor In [Enum].GetNames(colorsEnum)
alColors.Add(New DictionaryEntry(mColor,
GetEnumDescription(CType([Enum].Parse(GetType(Colors), mColor), Colors))))
Next mColor
Me.lstColors.DataSource = alColors
Me.lstColors.DataTextField = "Value"
Me.lstColors.DataValueField = "Key"
==========================================
--
Joe Fallon
"Kevin Johnson" <mc***@at1.uk.com> wrote in message
news:64**********************************@microsof t.com...
Hi
I have an ASP.NET datagrid written in C#. When editing my datagrid it
contains one dropdown list and 4 normal textboxes.
I need the dropdown list to contain all of the colors in the
System.Drawing.Color class for selection. I am unsure how to go about this.
Could anyone help and provide coded examples?
Any help highly appreciated.
Thanks
Kevin