enum and combobox

  • Thread starter Thread starter Franky
  • Start date Start date
F

Franky

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
 
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
 
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
 
Yes, as long as it supports the IList interface, you can just databind the
array that is returned to the combobox.

Mark
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top