list enum values in a combobox

B

Bas Cost Budde

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)
 
G

Guest

Example:
Public Enum Colors
Black = 0
White = 1
Green = 2
End Enum

How Can I then list these values in a combobox?
 
A

Alex Dybenko

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
 
T

Tim Ferguson

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

Top