list enum values in a combobox

  • Thread starter Thread starter Alex
  • Start date Start date
Alex said:
I would like to list enum values in a combobox. Is it
possible?

What is an enum value?

you can have anything in a combobox, as long as you can express it as a
delimited string, or it can be found in a table(query)
 
Example:
Public Enum Colors
Black = 0
White = 1
Green = 2
End Enum

How Can I then list these values in a combobox?
 
i think you can't. no way to read enum at runtime.
if you making some addin - you can try to read enum declaration as text of
module and then populate combobox with it
 
Public Enum Colors
Black = 0
White = 1
Green = 2
End Enum

How Can I then list these values in a combobox?

for n = 0 to 2
select case n
case Black : strRS = strRS & "Black;"
case White : strRS = strRS & "White;"
case Green : strRS = strRS & "Green;"
end case

next n

' chop off last semicolon & put into combo box
cboMyCombo.RowSource = Left(strRS, Len(strRS)-1))


Still think it's a bit redundant though...

HTH


Tim F
 

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

Similar Threads

about enum 3
How to poulate a combobox in wpf applikation 1
Enum TypeConverter 3
Propertygrig again and combobox 4
combobox 4
enum and combobox 3
Merge Info From Two Enums 1
Enum Extentions 7

Back
Top