471,319 Members | 2,675 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

enum and combobox

does anybody know how to use all values of an enumeration in a combobox?

i have an enum type defined like
public enum EnumTest
{
val1 = 1,
val2 = 2,
val4 = 4,
}

i would like to bind this to a combobox so that i can use 'val1' als the
displaymember of the combobox and the int as the valuemember.

any ideas?

thanks,
Dries
Dec 19 '05 #1
3 9703
Franky

You can use Enum.GetNames to return the constants used. Also, use
Enum.GetValues to return the values.

Use a loop to iterate over and assign to your combobox.

Mark

"Franky" <dr***@bestopia.be> wrote in message
news:11***************@seven.kulnet.kuleuven.ac.be ...
does anybody know how to use all values of an enumeration in a combobox?

i have an enum type defined like
public enum EnumTest
{
val1 = 1,
val2 = 2,
val4 = 4,
}

i would like to bind this to a combobox so that i can use 'val1' als the
displaymember of the combobox and the int as the valuemember.

any ideas?

thanks,
Dries

Dec 19 '05 #2
> Use a loop to iterate over and assign to your > combobox.

I think it can be done without the loop.
Look it up in the docs.
Roger
Dec 19 '05 #3
Yes, as long as it supports the IList interface, you can just databind the
array that is returned to the combobox.

Mark

"Roger" <ro***@pcsrevenuecontrol.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Use a loop to iterate over and assign to your > combobox.


I think it can be done without the loop.
Look it up in the docs.
Roger

Dec 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Cody Manix | last post: by
3 posts views Thread by frivard | last post: by
2 posts views Thread by Rene | last post: by
3 posts views Thread by cyshao | last post: by
7 posts views Thread by Harris | last post: by
3 posts views Thread by Desmond Cassidy | last post: by
5 posts views Thread by kjqua | last post: by
1 post views Thread by Gerrit | last post: by

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.