473,405 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Syste.Drawing.Color bound to a dropdown list

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
Nov 18 '05 #1
2 1683
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/tut...utorial_id=297

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"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

Nov 18 '05 #2
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

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Crazy Cat | last post by:
I am using a data-bound combobox with dropdownstyle set to dropdownlist. Teh combobox is bound to a bindingsource which is in turn bound to a table in my database. The table has only 4 rows and I...
6
by: blouie | last post by:
Is there a way that a bound ddl control can: 1. display the bound data, even if it does not match a selection in the DDL? 2. allow the user to enter something other than the look up values? I...
2
by: gleadams | last post by:
I have databound a Windows form ComboBox control to a DataSource and DataMember and it is properly showing the data as I navigate through the records. My question concerns the choices in the...
7
by: arti | last post by:
In ASP.Net, I have a Dropdown List bound to a City Table with City Id as Value & City names as Data Text field. I want to Show a few Favourite Cities on top as well as in their correct place in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.