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
 
Back
Top