473,320 Members | 1,900 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,320 software developers and data experts.

Get member name

Hi,
We have a long list of color name: Color.Red, Color.Green, Color.Green....
If I want to get the list of all color name (certainly by programming), how
to that ?
Thanks
Jul 19 '05 #1
2 1673
Hai,

If you want to get all the color names, then you would want to get all
of the static properties on the color structure. You can use reflection to
do this:

// Get the property info instances for all static properties on the Color
structure.
PropertyInfo[] pobjInfos =
typeof(Color).GetProperties(BindingFlags.GetProper ty | BindingFlags.Public |
BindingFlags.Static);

Then, you can cycle through the property infos and get the names of the
properties.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

" #Hai" <Re**********@Mail.com> wrote in message
news:eg**************@TK2MSFTNGP10.phx.gbl...
Hi,
We have a long list of color name: Color.Red, Color.Green, Color.Green....
If I want to get the list of all color name (certainly by programming), how to that ?
Thanks

Jul 19 '05 #2
An easier solution would be this:

Dim names() as String = [enum].GetNames(getType
(System.Drawing.Color))

Dim values() as integer = [enum].GetValues(GetType
(System.Drawing.Color))

Reflection is not needed in this case.. And this same
solution works for all enumerations.. ;)

Cheers..
-----Original Message-----
Hi,
We have a long list of color name: Color.Red, Color.Green, Color.Green....If I want to get the list of all color name (certainly by programming), howto that ?
Thanks
.

Jul 19 '05 #3

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

Similar topics

6
by: Nels Olsen | last post by:
Our company is rewriting our product in .NET. The old product is in PowerBuilder, which is heavy on Hungarian notation. We are approaching the time where we have to finalize naming conventions for...
2
by: Mark Sisson | last post by:
Hi all. SITUATION ================ 1. I have a base class with a member variable that's an object 2. I have several classes that inherit from the base class. 3. There are several methods in...
6
by: Bill Rubin | last post by:
The following code snippet shows that VC++ 7.1 correctly compiles a static member function invocation from an Unrelated class, since this static member function is public. I expected to compile the...
14
by: Dave Booker | last post by:
It looks like the language is trying to prevent me from doing this sort of thing. Nevertheless, the following compiles, and I'd like to know why it doesn't work the way it should: public class...
2
by: Carlos Rodriguez | last post by:
I have the following function in C#public void Undo(IDesignerHost host) { if (!this.componentName.Equals(string.Empty) && (this.member != null)) { IContainer container1 = (IContainer)...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.