Syste.Drawing.Color bound to a dropdown list

Discussion in 'ASP .Net' started by =?Utf-8?B?S2V2aW4gSm9obnNvbg==?=, May 23, 2004.

  1. H

    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

    Thank

    Kevin
    =?Utf-8?B?S2V2aW4gSm9obnNvbg==?=, May 23, 2004
    #1
    1. Advertising

  2. Perhaps you could use Reflection to detect all the colors -- since there is
    no collection of colors, and the colors are merely static members of
    System.Drawing.Color class. Here's an example of how to use reflection:

    http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=297

    --
    Manohar Kamath
    Editor, .netWire
    www.dotnetwire.com


    "Kevin Johnson" <> wrote in message
    news:...
    > 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
    Manohar Kamath [MVP], May 24, 2004
    #2
    1. Advertising

  3. =?Utf-8?B?S2V2aW4gSm9obnNvbg==?=

    Joe Fallon Guest

    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" <> wrote in message
    news:...
    > 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
    Joe Fallon, May 24, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?aW5ldG11Zw==?=
    Replies:
    0
    Views:
    444
    =?Utf-8?B?aW5ldG11Zw==?=
    May 27, 2005
  2. PJ6
    Replies:
    4
    Views:
    4,879
  3. steve
    Replies:
    2
    Views:
    758
    steve
    Dec 12, 2004
  4. Shree
    Replies:
    0
    Views:
    2,110
    Shree
    Sep 2, 2006
  5. inetmug
    Replies:
    2
    Views:
    199
    inetmug
    Jun 3, 2005
Loading...

Share This Page