• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 513
  • Last Modified:

Add whole enum to combobox


how can i add all the items of an enum to a combobox (not having to code each one)

example enum:

Public Enum MP_Maps
   mp_breakout
   mp_toujane
   mp_trainstation
End Enum


now i can do this:

combo1.additem mp_maps.mp_breakout
combo1.additem mp_maps.mp_toujane
combo1.additem mp_maps.mp_trainstation

but when the enum is longer this is quite much work....
0
Mark_FreeSoftware
Asked:
Mark_FreeSoftware
  • 3
  • 3
  • 3
  • +1
1 Solution
 
bruintjeCommented:
Hi Mark_FreeSoftware,
----------

if you use a hidden member in the enum to end counting in a for each loop

this is shown here
http://tinyurl.com/r3rd8

----------
bruintje
share what you know, learn what you don't
0
 
Mark_FreeSoftwareAuthor Commented:

@ bruintje,

can i add the text to the combobox instead of the number?

(i don't have a pc available to try it out now)
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
bruintjeCommented:
tried that but i don't think that is going to work that way except for your first comment doing them one by one
it's not an array which will make such a loop possible

the for i to x loop in the links above will only doing the numbers
0
 
basicinstinctCommented:
Sorry, am I missing something here?  What's to stop you doing this?

For i = mp_breakout to mp_trainstation
      combo1.additem mp_maps.i
Next
0
 
bruintjeCommented:
did not test that but if that works you got the answer :)
0
 
Mark_FreeSoftwareAuthor Commented:
>>Sorry, am I missing something here?  What's to stop you doing this?

this error:
method or data member not found


vb doesnt like the ".i"
0
 
basicinstinctCommented:
Well I'm still not 100% sure what you are trying to do...  Is this it?

For i = mp_breakout to mp_trainstation
     combo1.additem i
Next
0
 
basicinstinctCommented:
When you do it manually like this:

  combo1.additem mp_maps.mp_breakout
  combo1.additem mp_maps.mp_toujane
  combo1.additem mp_maps.mp_trainstation

What actually would be the items displayed in the combobox at runtime?
0
 
Mark_FreeSoftwareAuthor Commented:

>> What actually would be the items displayed in the combobox at runtime?

the numbers also.


basically what i want is this:

all the names added to the combobox, so i can choose one.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now