By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,053 Members | 922 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,053 IT Pros & Developers. It's quick & easy.

enumerating enum options

P: n/a
Hi all, I currently have a custom vb object which has several Enum
properties. Now, on the end-user web form I am manually displaying a
drop-down list with the options for each of these properties. It would be
nice if I could somehow "read" the various enum options and generate the
drop-down list on the fly. This way, all I have to do is change the vb
object file everytime I want to change any of the enum options and eliminate
having to change the web form too. Any ideas how I can do this?

TIA!
Nov 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Any ideas how I can do this?


The System.Enum type and its GetNames method is a good start.

Just keep in mind that names that make sense to a programmer don't
always make sense to an end user. You can't include spaces and it's
not a very localization friendly way of doing things.
Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 23 '05 #2

P: n/a
Hi,

Currently, I am not sure I understand your request very well. Does mattias'
suggesiton of using Enum.GetNames method meet your need? This method will
retrieve all the constant filed names of your enum type, then you can
enumerate through this string collection and populate the dropdown list
yourself.

If we misunderstand you, please feel free to tell us, and a more detailed
and concrete description will be helpful. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 23 '05 #3

P: n/a
Yes, that is what I want to do. I will try it out soon and let you know.

thanks!

""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:JD**************@TK2MSFTNGXA02.phx.gbl...
Hi,

Currently, I am not sure I understand your request very well. Does
mattias'
suggesiton of using Enum.GetNames method meet your need? This method will
retrieve all the constant filed names of your enum type, then you can
enumerate through this string collection and populate the dropdown list
yourself.

If we misunderstand you, please feel free to tell us, and a more detailed
and concrete description will be helpful. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 23 '05 #4

P: n/a
Ok, if you need any further help, please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.